PlotPub
=======
<h4>Publication quality graphs in MATLAB.</h4>
MATLAB is an excellent tool. It is equally popular among students, researchers
and professors. If you use MATLAB for your project/research, you probably know
that it is not easy to create publication quality graphs (PQGs) using MATLAB.
You will have to call a billion <code>set</code> and <code>get</code> functions
to create a decent plot with desired height, width, fonts, line width, color
etc. Here, I present PlotPub which is a collection of MATLAB functions and
a MATLAB class that allows you to modify almost all aspects of MATLAB figures
and export PQGs using one function call and a simple structure.MATLAB是一个很好的工具。
它同样受到学生、研究人员和教授的欢迎。
如果您在项目/研究中使用MATLAB,您可能知道使用MATLAB创建发布质量图并不容易。
你要拨打十亿组<代码> < /代码>和<代码> < /代码>函数来创建一个像样的情节与所期望的高度,宽度,字体、线宽、颜色等。在这里,我现在PlotPub MATLAB函数和一个MATLAB类的集合,使用一个函数调用和一个简单的结构允许您修改MATLAB的几乎所有方面的数据和导出PQGs。
<h4>What's new in v2.2</h4>
<hr />
<ul>
<li>Added SVG and fig to exports (issue # 9). Thanks to <a href="https://github.com/hsidky">Hythem Sidky</a></li>
<li>Added X/Y/ZTickLabels. Thanks to <a href="https://github.com/hsidky">Hythem Sidky</a>.</li>
<li>Fixed bug # 6. Thanks to <a href="https://github.com/ChuntaoLu">ChuntaoLu</a>.</li>
<li>Fixed bug # 5. Thanks to <a href="https://github.com/protik77">Protik Das</a>.</li>
</ul>
<h4>What's new in v2.1</h4>
<hr />
<ul>
<li>Fixed constructor for user supplied handle. Thanks to
<a href="https://github.com/hsidky">Hythem Sidky</a>.</li>
<li>Added a new function, <code>setPlotProp2(hfig, opt)</code>
for compatibility with MATLAB line and patch functions.</li>
</ul>
<h4>New features of v2.x</h4>
<hr />
<ul>
<li>Simple and elegant object oriented approach: all aspects of the MATLAB
figure is encapsulated in the Plot class.</li>
<li>Create new plots, open saved figures or change existing figure using
the same call, <code>Plot()</code>.</li>
<li>Control every aspect of a MATLAB figure using the Plot class object.</li>
<li>Property changes are immediately visible, useful when using from command
window.</li>
<li>Even easier to use.</li>
<li>Fully compatible to v1.x.</li>
</ul>
<h4>What's new in v1.4</h4>
<hr />
<ul>
<li>Added the title option.</li>
</ul>
<h4>What's new in v1.3</h4>
<hr />
<ul>
<li>Several bugs fixed including marker spacing.</li>
<li>New options for axis color, axis line width, tick direction, tick
length, minor ticks, legend box, legend text color etc.</li>
<li>New, more appealing default look.</li>
</ul>
<h4>Features of v1.x</h4>
<hr />
<ul>
<li>Generate beautiful, publication quality graphs from instantly generated
MATLAB figures or saved MATLAB fig files.</li>
<li>Export figures in EPS, PDF, JPEG, PNG and TIFF with adjustable
resolution.</li>
<li>Set marker spacing.</li>
<li>Change almost all aspects of a figure using simple and intuitive
code.</li>
<li>A lot of example codes. A decent tutorial and good documentation.</li>
<li>Tested in Ubuntu and OSX with MATLAB 7.10. But it should work in other
operating systems with other versions of MATLAB.</li>
<li>Distributed under BSD license which allows you to do anything you
like.</li>
</ul>
<h4> Compatibility with v1.1</h4>
<hr />
In version 1.2, I introduced a new function <code>setPlotProp</code> which is
superior to the old function <code>plotPub</code>. But for backward
compatibility, <code>plotPub</code> is still available in v1.2. Therefore, all
of your previous codes should work with v1.2.
<h4>Downloads</h4>
<hr />
<ul>
<li><a href="https://github.com/masumhabib/PlotPub/archive/master.zip">Compressed package</a></li>
</ul>
<h4>Documentation证明文件</h4>
<hr />
<h5>Installation</h5>
<hr />
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 <code>lib</code> 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从上面给出的链接下载并提取zip文件。
使用三种可能的方法之一安装PlotPub:(1)复制所有*。
在<code>lib</code>文件夹中的m个文件,可以将这些文件复制到您当前的项目文件夹中,也可以将plotpubm -master放在任何方便的文件夹中,并在您的MATLAB代码中添加如下一行:
<code> addpath('D:/MATLAB/PlotPub-master/lib');</code>
where, I assume that you put PlotPub-master in <code>D:/MATLAB</code> folder.
The sample codes can be found inside the <code>examples</code> folder其中,假设您将plotpubd -master放在<code>D:/MATLAB</code>文件夹中。
示例代码可以在<code>examples</code>文件夹中找到。.
<h5>Tutorial</h5>
<hr />
* [Tutorial for v1.4](https://github.com/masumhabib/PlotPub/wiki/Tutorial-for-v1.4)
To create a beautiful figure using PlotPub, all you need to know is how to use
the (<code>Plot</code>) class. Alternatively, you can use the
set-plot-properties (<code>setPlotProp</code>) function which
is discussed [here](https://github.com/masumhabib/PlotPub/wiki/Tutorial-for-v1.4). 要使用PlotPub创建一个漂亮的图形,您只需知道如何使用(<code>Plot</code>)类。
或者,您也可以使用set-plot-properties (<code>setPlotProp</code>)函数,我们将讨论这个函数
The Plot class provides a simple and elegant object oriented programming
interface for manipulating MATLAB figures.
Let us walk you through an example. Assume that we have data for 3 cycle of a
50 Hz AC voltage signal:
```matlab
clear all;
%% lets plot 3 cycles of 50Hz AC voltage
f = 50; % frequency
Vm = 10; % peak
phi = 0; % phase
% generate the signal
t = [0:0.0001:3/f];
th = 2*pi*f*t;
v = Vm*sin(th+phi);
% plot it
figure;
plot(t*1E3, v);
```
where, <code>f</code> is the frequency, <code>Vm</code> is the peak voltage,
<code>t</code> is time and <code>v</code> is the AC voltage signal. Result?
An utterly ugly looking figure punching at your face其中,<code>f</code>为频率,<code>Vm</code>为峰值电压,<code>t</code>为时间,<code>v</code>为交流电压信号。
结果呢?
一个丑陋无比的人在打你的脸:
<a href="http://masumhabib.com/wp-content/uploads/2014/09/ugly.png"><img class="aligncenter size-full wp-image-1325" src="http://masumhabib.com/wp-content/uploads/2014/09/ugly.png" alt="MQGv1.3: ugly"/></a>
Now, let us add some spices. Let us set the labels and title:
```matlab
% change settings
plt = Plot(); % create a Plot object and grab the current figure
plt.XLabel = 'Time, t (ms)'; % xlabel
plt.YLabel = 'Voltage, V (V)'; %ylabel
plt.Title = 'Voltage as a function of time'; % plot title
```
Finally, call the <code>export</code> function to export the figure:
```matlab
% Save? comment the following line if you do not want to save
plt.export('plotSimple1.png');
```
The resulting plot should look like:
![MQGv2.0: Simple plot](https://github.com/masumhabib/PlotPub/blob/v2.0/examples_class/plotSimple1.png)
Instead of creating the plot using
```matlab
% plot it
figure;
plot(t*1E3, v);
```
one could also use Plot class directly to plot:
```matlab
plt = Plot(t*1E3, v); % create the figure directly using data
plt.XLabel = 'Time, t (ms)'; % xlabel
plt.YLabel = 'Voltage, V (V)'; %ylabel
plt.Title = 'Voltage as a function of time'; % plot title
```
The full source code for this plot, <code>plotSimple.m</code>, can be found
inside the <code>examples_class</code> folder.此图的完整源代码,<code>plotSimple。
m</code>,可以在<code>examples_class</code>文件夹中找到。
We can chan