File Exchange

image thumbnail

PlotPub - Publication Quality Graphs in MATLAB

version (3 MB) by K M Masum Habib
PlotPub is a MATLAB library for creating beautiful, publication quality figures.


Updated 22 Jun 2018

View License on GitHub

PlotPub is a free and open source MATLAB library for creating beautiful, publication quality graphs from instantly generated MATLAB figures or saved MATLAB fig files. This library provides a simple and easy way to modify almost all aspects of a MATLAB figure. It can export figures in EPS, PDF, JPEG, PNG and TIFF with adjustable resolution. The default settings in PlotPub can produce decent, publication ready graphs right out of the box.

New features of v2.x
- Simple and elegant object oriented approach: all aspects of the MATLAB figure is encapsulated in the Plot class.
- Create new plots, open saved figures or change existing figure using the same call, Plot().
- Control every aspect of a MATLAB figure using the Plot class object.
- Property changes are immediately visible, useful when using from the command window.
- Even easier to use.
- Fully compatible to v1.x.

What’s New in v1.3?
- Several bugs are fixed including marker spacing.
- New options for axis color, axis line width, tick direction, tick length, minor ticks, legend box, legend text color etc.
- New, more appealing default look.

Features of v1.x
- The default settings can generate beautiful, publication quality graphs out of the box.
- Supports instantly generated MATLAB figures and saved MATLAB fig files
- Export figures in EPS, PDF, JPEG, PNG and TIFF with adjustable resolution.
- Adjustable marker spacing.
- Change almost all aspects of a figure using simple and intuitive code.
- A lot of example codes. A decent tutorial and good documentation.
- Tested in Ubuntu and OSX with MATLAB 7.10. But it should work in other operating systems with other versions of MATLAB.
- Distributed under BSD license which allows you to do anything you like.

Please visit the project page at for tutorial and documentation.

Download and extract the zip file from the link given above. Install PlotPub using any one of the three possible ways: (1) copy all the *.m files inside the lib folder to either your MATLAB path or (2) copy those files to your current project folder or (3) put plotPub-master in any convenient folder and add the following line in your MATLAB code:


where, I assume that you put PlotPub-2.0 in D:/MATLAB folder. The sample codes can be found inside the examples folder.

Bugs and Feature Request
If you find any bug/problems/issues, please report it on the GitHub page at If you want new features, please add a request there.

Known issues
- Does not work with sub-figures.

Comments and Ratings (33)


really helpful!

Amazing stuff Masum Bhai!

I was wondering if there's any way to manipulate the width of a bar plot? When I am using the 'grouped' feature, the bar width becomes too low.

Thanks for providing us this splendid tool!

junmin wang

so good work!

Ahmad Ali

This is excellent tool for plot (2D or 3D) function. Is there any similar function for mesh plots?

Excellent, It is really helpful!
Help me please:
How can I set latex font? I was trying putting 'Interpreter', 'latex' after Opt.FontName but it doesn't work

Adnan Ali

Normalizing units won't work.Please define a new class. Thank you


I solved the issue just by removing the line:
'Color', Colors(ii,:), ...
in setPlotProp.m
Then the print just uses the predefined colors. It works for bar graphs and histograms e.g.

K M Masum Habib

@Bee Given below is an example of how to use PlotPub for a bar-plot:

clear all;

% Change the following line according to your path to PlotPub

y = [75 91 105 123.5 131 150 179 203 226 249 281.5];
fig_handle = figure;

plt = Plot(fig_handle, true);
plt.XLabel = 'Test';
plt.YLabel = 'Data (%)';


Bee (view profile)

Dear Masum, Thanks a lot for your contribution. I was wondering whether it is compatible with bar-plots or histogram-plots. I tried to use the Plot command to grab a bar-plot which produces error while using Because there is no color property on the Bar Class.


Bee (view profile)

K M Masum Habib


Currently, PlotPub does not support automatic x ticks as multiple of pi. However, it is pretty easy to add xticks manually:

plot.XTick = [pi/4, pi/2, 3*pi/4];

Since, this is a very special case, we do not have a plan to implement it near future.

However, if you are talking about xtick labels, please post a feature request in github, and we might implement it in a future release. Even better, if you have an implementation, and send me a pull request, I'll be happy to merge it.

Masum Bhai,

Just started to use your tool. It is amazing.

Just a little feature suggestion: can you add an automatic option of having x ticks as multiples of Pi? (pi/4, pi/2, 3/4*pi etc). It is possible to do it manually, but would be great if the tool supported it.

K M Masum Habib

@Marcin, Thanks for reporting bug. To help it fixed, please file a bug report on github project page. Please provide us with the following: (1) OS name and version, (2) MATLAB version and (3) provide a script that can reproduce the bug (if possible).

great tool! I'm big fan! But... version 2.2 is not saving/printing data drive, error is some where in the Plot.m function around 923 line. After changing it back to situation from ver. 2.1 functionality restored.
I commented:
%set(0, 'Units', 'inch');
%monitorPos = get(0,'MonitorPositions');
%pos = [monitorPos(1,3)/2-self.boxDim(1)/2, monitorPos(1,4)/2-self.boxDim(2)/2];

and replaced with
pos = get(self.hfig, 'Position');

didn't have time to analyse why and what is wrong, just wanted to restore its functionality.


JEng (view profile)

This really is an excelent tool for fast good looking graphs.


JEng (view profile)

VItor ribeiro

Good tool to costumize the apeearance of the plots. However i prefer to use it with export_fig for exporting the matlab figures to eps format. Export_fig renders better the figures than the print command of matlab specially the minor grid lines. However if one does not need minor grid lines print command of matlab may be an alternative since export-fig seems to overshadow the fonts while print command has lighter fonts.

@Leon, To use HoldLines, you'll have to construct a Plot object like: plt = Plot(hfig, true) where hfig is the figure handle and true is holdLine.

Gives very appealing graphs, great work!

I have on problem though, when using the HoldLines property. If I do: something like
plt = Plot();
plt.HoldLines = true;

I get "No public field HoldLines exists for class Plot"

I have version 2.1. It seems like the HoldLines set function is missing...


haijie (view profile)


Lei (view profile)

What about figure with multiple axes?

Great tool to customized plots

K M Masum Habib

@Yair, thanks for the comment and the suggestion. For setPlotProp function, hfig is an optional parameter. If not given, setPlotProp will grab the current figure handle. That is why I made it second parameter.

However, I created another function setPlotProp2(hfig, opt) which will be available in the next release.

Yair Altman

Many Matlab users are not aware that we can use the struct format (as well as the commonly-used P-V args format) with line, patch and other plotting functions. For example:

lineProps.Marker = '*';
lineProps.MarkerSize = 15;
lineProps.MarkerEdgeColor = 'b';
lineProps.color = 'r';
lineProps.xdata = 1:5;
lineProps.ydata = 3:7;

hLine = line(lineProps);
set(hLine, otherLineProps);

I blogged about this a few years ago:

A suggested improvement: support reversed inputs, i.e., hFig before the options struct. This would be in line with Matlab functions that typically accept the handle as their first input and all the parameters as 2nd+ inputs. Just a thought...

@Amit, Could you post the full error message and send me the full matlab file for the plot?

Amit Sharma

It goes in the script like this under the plot command.

" opt= [];

opt.BoxDim = [6, 4]; %[width, height] in inches
opt.FontSize = 18;
opt.LineStyle = {'no', 'no'};
opt.LineWidth = [1, 1];
opt.Markers = {'o', 's'};
opt.Colors = [ % two colors for three data set
1, 0, 0; % data set 1
0, 0, 1; % data set 2
opt.Legend = {'a', 'b'}; % legends

opt.FileName = 'filename.pdf';

I am using Matlab version R2014b and this used to work fine but now I get a message saying error in setPlotProp(opt).
Can you please provide an help to trouble shoot the issue.

K M Masum Habib

@Matthew. Thanks for the comment. PlotPub provides a *simple and easy* way to modify the properties of a figure (setting line style, markers, colors .. virtually all aspects of a figure). It also gives the user a way to export the figure to image files (EPS, PNG ... etc).

If I understood correctly, export_fig provides a way to export figures to image files only. The figure properties must be set by complex get/set methods.


You have a lot of documentation that doesn't seem to answer the simple question: Why should a MATLAB user use this PlotPub over export_fig?

Somaia Sylvia

Has been very useful for my publications. It makes life easier.

K M Masum Habib

PS. I would like to acknowledge this beautiful article on how to create publication quality figures:


Fixed a typo.

Updated description.

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux

MATLAB Online Live Editor Challenge

View the winning live scripts from faculty and students who participated in the recent challenge.

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video