How to export a saved fig file to eps using command? - matlab

Suppose I have a matlab figure s1.fig. I want to save it as a eps file. I can do this manually (file>export setup>export............). Is there any way to do this using command only without touching the file s1.fig.

You have a couple of ways. One is to use export_fig from Matlab FEX (which is the solution I favour more). However, you can also do:
figure()
...
saveas(gcf,'filename.ext')
Using saveas
In my experience, export_fig gives nicer plots, with antialiasing, and some other nice features. However, if you are using Matlab 2014b, the figure engine has changed and should give you good quality plots also.

Related

How does export_fig compare to the new exportgraphics function in Matlab?

When saving plots to PDF in MATLAB one had to use a tool like export_fig in order to prevent that the PDF looks totally different from the plot on the screen.
export_fig added a hint to use exportgraphics from MATLAB in a commit in 2020
What should a user keep in mind when deciding whether to use the internal exportgraphics or the external export_fig tool with MATLAB 2022a or later?
What are the major differences?

how to save matlab neural networks toolbox generated figures

In the matlab workspace the output/results can be easily saved. But when I train the network with some data to see the performance of the training (In Neural Network Toolbox), the regression plots along with the histograms and performance plots can not be saved as a figure file.currently i am using snipping tools to capture them.
My Question is how to do that? Is there any options to save those plots(generated in Maltab Neural Network toolbox)?
I would be grateful to have any codes/ answers regarding my inquiry. Many thanks.
I am adding to snapshot of plots which i want to save by commanding codes in matlab.
currently i am using snipping tools but when i put then in word, their property/image quality shrinks.
First of all you need to identify the gfx object you want to snap-shoot (its handle). This may come from identifiable properties. Then you'd want to use print to save it to a file; you need to provide the file name, eventually the type; see the help for more details.
For example, if you want to save the figure with the tag 'my.awesome.fig', you may try:
h = findobj('Type', 'figure', 'tag', 'my.awesome.fig');
for k = 1:numel(h)
print(h(k), sprintf('Pic%d.ps',k));
end;
The training figures other than nntraintool itself are genuine matlab figures. The tags are for example TRAINING_PLOTERRHIST TRAINING_PLOTPERFORM TRAINING_PLOTRESPONSE . the nntraintool figure is java--you can access it with nnjava.tools('nntraintool'). See Undocumented Matlab for how to manipulate java figures in Matlab.
Richard
If you mention about the quality of figures only, you can do it by clicking EDIT/COPY in the figure menu.

Creating figures for publication - artefacts in export

Now I am already trying for hours to get a satisfying vectorized output from a 3D matlab plot. I illustrated the artefacts of the resulting pdf exports in the following image (created with export_fig -> -r2000). I know that this problem is somehow related to the pdf viewer, but is there no solution to get a compatible output for all viewers?
In addition I have tried libs like plot2svg and matlab2tikz, but they seem to have problems with some of my surface plots resulting in completely different problems.
If there are no other ways to create vectorized outputs of the figures, do you have any tips for high quality bitmap figures (especially regarding to the font blurring)?
From my experience, exporting matlab figures results with less than satisfying results.
Personally, I prefer to export the data to other programs and create the plots there.
Excel does pretty good job with many types of figures. You may also try gnuplot.
I know this is not exactly the answer you are looking for but sometime instead of fighting Matlab, it is best to leave this jobs to better suited software.

Dynamic Plotting in Gnuplot (drawnow in MATLAB)

Is it possible to create dynamic plots in Gnuplot? What I require for my purposes is that, as the data is generated through some loop, I will use gnuplot to put some marker on the x-y axis preserving the older ones. So somehow I will be able to observe the evolution of the data instead of just seeing the final batch result.
What I specially want is equivalent to "drawnow" command in MATLAB.
Although not totally related, right now I am using common lisp to generate the data in a loop and cgn in order to plot within lisp using gnuplot. (I can plot data in batch form inside common lisp using cgn which utilizes gnuplot)
Thank you very much in advance for your attention.
edit: I have a written a code in common lisp for this purpose. You can check it here :
Plotting data sequentially from emacs using Common Lisp and Gnuplot
This thread is however more general and asks dynamic plotting in gnuplot. Any suggestions are welcome.
Unfortunately it's not easy to plot single points in gnuplot, but luckily there are some simple hacks as discussed here: Plotting a Single Point with Gnuplot. The echo method discussed there will only work in a Unix environment though.
Using this with replot instead of plot in your program should hopefully give you a graph of points evolving with time that preserves the previous points.
Another way, which is what I use with python, is that I put the data points in a file. In every iteration, I add points to the file then plot with gnuplot again. It's a little ugly, but it does the job in most cases.
I'm not sure that I completely understand what you are asking, but if you're looking to add a plot to the last string you plotted (and you're using gnuplot 4.4), the following does the trick:
gnuplot> plot sin(x),cos(x) #plot sin and cos in an xterm window
gnuplot> eval GPVAL_LAST_PLOT."cos(x+pi/2.5)" #add cos(x+pi/2.5) to the current plot
Anyway, I'm not sure if that's what you're asking for as I don't use Matlab, but I hope it is.

Do the MATLAB functions imread and imwrite belong to the image processing toolkit?

Do the MATLAB functions imread and imwrite belong to the image processing toolkit? The names seem to suggest that they do, but I'm not sure. Can anyone give some info?
No, imread and imwrite are part of the core MATLAB toolbox.
Reading from or writing to image files is a basic IO process, and one that many people will likely have need to do without any need for processing the images. For example, if you just want to display an image in a figure, you shouldn't need a whole new high-powered image processing toolbox just to do that. That's why there are simple functions like image and imagesc present in the core MATLAB toolbox, while the Image Processing Toolbox has an additional imshow function that has a few more bells and whistles.
In general, you'll find that a lot of basic/common operations are present in the core MATLAB toolbox, while the more advanced operations require a specialized toolbox. The names of the functions themselves won't really tell you which toolbox they belong to, but you can use the which function if you are ever in doubt about where a function lives. For example, for MATLAB R2009a:
>> which imread
C:\Program Files\MATLAB\R2009a\toolbox\matlab\imagesci\imread.m
% ^---- Core MATLAB toolbox
>> which imshow
C:\Program Files\MATLAB\R2009a\toolbox\images\imuitools\imshow.m
% ^---- Image Processing Toolbox