PlotPub!一款让你欲罢不能的科研绘图工具箱
- 2019 年 10 月 29 日
- 筆記
PlotPub是K. M. Masum Habib开发的一款高质量绘图工具箱,作者将绘图相关的设置全部封装在了一个名为“Plot”的类中,只需要简单的设置即可绘制一幅漂亮的图像。该工具箱支持EPS, PDF, PNG, JPEG,TIFF和SVG等格式文件的输出,接下来就一起来看看作者的漂亮示例吧:
示例一、多曲线制图
% 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');

示例二、多曲线多标记制图
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');

示例三、双对数坐标制图
% 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');
