前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >PlotPub!一款让你欲罢不能的科研绘图工具箱

PlotPub!一款让你欲罢不能的科研绘图工具箱

作者头像
巴山学长
发布2019-10-29 16:26:06
1.9K0
发布2019-10-29 16:26:06
举报
文章被收录于专栏:巴山学长巴山学长
在matlab中绘制高质量图应该困

PlotPubK. M. Masum Habib开发的一款高质量绘图工具箱,作者将绘图相关的设置全部封装在了一个名为“Plot”的类中,只需要简单的设置即可绘制一幅漂亮的图像。该工具箱支持EPS, PDF, PNG, JPEG,TIFFSVG等格式文件的输出,接下来就一起来看看作者的漂亮示例吧:

示例一、多曲线制图

代码语言:javascript
复制
% Multiple plots using plotPub
clear all;
% 将库文件添加到matlab搜索路径中
addpath('../lib');
%% lets plot 3 cycles of 50Hz AC voltage
f = 50;
Vm = 10;
phi = pi/4;
% generate the signal
t = [0:0.0001:3/f];
th = 2*pi*f*t;
v1 = Vm*sin(th);
v2 = Vm*sin(th - phi);
v3 = Vm*sin(th - phi*2);
%% plot and settings
plt = Plot(t*1E3, v1, t*1E3, v2, t*1E3, v3);
% 坐标轴设置
plt.XLabel = 'Time, t (ms)'; % xlabel
plt.YLabel = 'Voltage, V (V)'; %ylabel
plt.YTick = [-10, 0, 10];
plt.YLim = [-11, 11];
% 保存绘制图像
plt.export('plotMultiple.png');

示例二、多曲线多标记制图

代码语言:javascript
复制
clear all;
% load previously generated fig file
figFile = 'multiple.fig';
plt = Plot(figFile);
% change properties
plt.XLabel = 'Time, t (ms)'; % xlabel
plt.YLabel = 'Voltage, V (V)'; %ylabel
plt.YTick = [-10, 0, 10]; %[tick1, tick2, .. ]
plt.XLim = [0, 80]; % [min, max]
plt.YLim = [-11, 11]; % [min, max]
plt.Colors = { % three colors for three data set
    [ 1,      0,       0]
    [ 0.25,   0.25,    0.25]
    [ 0,      0,       1]
    };
plt.LineWidth = [2, 2, 2]; % three line widths
plt.LineStyle = {'-', '-', '-'}; % three line styles
plt.Markers = {'o', '', 's'};
plt.MarkerSpacing = [15, 15, 15];
plt.Legend = {'\theta = 0^o', '\theta = 45^o', '\theta = 90^o'}; % legends
% Save? comment the following line if you do not want to save
plt.export('plotMarkers.png');

示例三、双对数坐标制图

代码语言:javascript
复制
% Log-log scale.
clear all;
addpath('../lib');
%% lets plot 3 cycles of 50Hz AC voltage
f = 50;
Vm = 10;
phi = 0;
% generate the signal
t = [0:0.00001:3/f];
th = 2*pi*f*t;
v = Vm*sin(th+phi);
vsqr = v.^2;

%% plot and settings
plt = Plot(t*1E3, vsqr);
plt.XLabel = 'Time, t (ms)'; % xlabel
plt.YLabel = 'Voltage, V (V)'; %ylabel
plt.YScale = 'log'; % 'linear' or 'log'
plt.XScale = 'log'; % 'linear' or 'log'
plt.YLim = [1E-3, 1E3]; % [min, max]
plt.YTick = [1E-3, 1E-1, 1E1, 1E3]; %[tick1, tick2, .. ]
plt.YGrid = 'on'; % 'on' or 'off'
plt.XGrid = 'on'; % 'on' or 'off'

% 保存图像
plt.export('plotSimpleLogLog.png'); 
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-10-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 巴山学长 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档