How to make nice plots?
270 次查看(过去 30 天)
显示 更早的评论
Hello
Will plot in Matlab with the following code.
a = [1.23, 2.34, 5.55, 7, 13.21, 15.66, 18, 20]
x = 1:size(a);
figure('Name', 'Simple plot', 'NumberTitle', 'off');
plot(x, a, '-o');
xlabel('test');
ylabel('test');
I would like to include the plot in a paper which I'm writing, i.e. it should look really nice.
How can I make the plot looking better with Matlab?
2 个评论
采纳的回答
Kelly Kearney
2014-6-9
I suppose everyone will have their own preferences for what looks "really nice". I use pdflatex to write most of my articles, and yes, I include figures via \includegrapics. There are some Matlab packages on the FEX to export figures to programatic latex graphics (e.g. TikZ), but most journals I've worked with prefer or require separate graphics files in the more common .png, .pdf, .eps, .jpeg, etc. format.
Some tips I use for getting nice, professional-looking graphics:
2) Make sure your figures, and everything in them, are properly-sized for the paper before exporting. Export using an appropriate resolution (at least 150 dpi, 300 dpi if file size doesn't prohibit it).
3) I usually change the fonts for all axis labels, titles, etc. (and sometimes the tick labels themselves, if they're not too small) to a serif font to match the rest of the text in the paper.
4) Don't rely on the default jet colormap. In addition to the fact rainbow colormaps are almost always a poor choice for visualizing data, I find that published figures that rely on it (and in my field, there are a lot of them) scream "I used Matlab and am lazy!" That's just a personal opinion, of course, but it just doesn't look very professional to me.
10 个评论
Kelly Kearney
2014-6-16
@Sepp
Hey, look what I found with a quick google search for "IEEE transactions artwork guidelines": http://www.ieee.org/documents/eic-guide.pdf. Not entirely sure this particular document is up to date, but if not I'm sure there's a newer version out there if not, probably under Author Guidelines on their website.
So it looks like they have an explicit list of fonts they prefer. Type listfonts in Matlab to see which fonts you have installed on your system. Then choose whichever one you want (keeping in mind that depending on the renderer, there are some limitations to which fonts Matlab uses when exporting to file, as described here). Also, note that they want .tiff files for bitmap artwork, not .png.
---
@Cedric, Star
This is turning into a tutorial, isn't it? I like the idea of a series that explains some of these more complex tasks in detail, with examples, links to articles, etc. A Matlab-for-LaTeX-publications tutorial could also include tips on auto-generating tables, including formatted code, etc.
And I agree, accumarray is another great candiate for this. It's such a useful and powerful function, and most people overlook it due to its somewhat cryptic documentation.
Star Strider
2014-6-16
For those brilliant enough to write an article of sufficient excellence to submit to Science, its guidelines are Science: Information for Authors and Preparing Your Manuscript and Figures.
更多回答(5 个)
Star Strider
2014-6-9
I can’t help with LaTeX, but I added a tag to your question so someone with the appropriate knowledge of LaTeX will see it.
The plot part simply requires that you plot two identical values for x and then use the two-element vector ylim (that MATLAB calculates as the y-axis limits for the plot) to define the y-coordinates of the line. That creates the vertical line from the lower to the upper y-limits of the plot, and changes dynamically if you change the data or y-axis limits in your plot.
The code:
a = [1.23, 2.34, 5.55, 7, 13.21, 15.66, 18, 20];
x = 1:size(a,2);
figure('Name', 'Simple plot', 'NumberTitle', 'off');
h=plot(x, a, '-o');
hold on % Plot additional information
plot(x(3), a(3), 'pr') % Plot the point in red
plot([x(3); x(3)], ylim, '-r') % Plot the vertical line in red
hold off % Stop adding plotted data
xlabel('test');
ylabel('test');
I arbitrarily chose x(3) and a(3). Make the appropriate changes to plot the point you want.
0 个评论
Image Analyst
2014-6-11
You might try Waterloo: http://www.mathworks.com/matlabcentral/answers/56890-publication-quality-graphics-in-matlab
1 个评论
Malcolm Lidierth
2014-6-11
Thanks for another plug IA.
Although it will not run in MATLAB yet (it requires Java 8+), there is a new version of Waterloo on the way: waterlooFX uses pure JavaFX and many Java 8 features (e.g. streams, lazy evaluation etc).
A pre-release snapshot with demo is available at:
Installers for the demo with an embedded Java 8 is available for win64 and MacOS platforms.
ML
Henric Rydén
2014-6-9
You can use the hidden LineSmoothing property. Something like this:
a = [1.23, 2.34, 5.55, 7, 13.21, 15.66, 18, 20]
x = 1:size(a,2);
figure('Name', 'Simple plot', 'NumberTitle', 'off');
h=plot(x, a, '-o');
xlabel('test');
ylabel('test');
set(h,'LineSmoothing','On')
0 个评论
Joshua Hrisko
2018-2-16
编辑:Joshua Hrisko
2018-2-16
I recommend using a function to improve the visuals of every plot, that way you can call the function and get quality plots each time. Try calling a function similar to the one below (based on my tutorial, found at Publication-Quality Plots - Engineer's Portal) :
function [fig1,ax1,dcm_obj] = fig_open()
set(0,'defaultfigurecolor',[1 1 1]) % white background
set(0,'defaultaxesfontname','cambria math') % beautify the axes a bit
scrn_size = get(0,'ScreenSize'); % get size of screen
shrink_pct = 0.1; % shrink the figure by 10%
%
fig1 = figure('Visible','off','DefaultAxesFontSize',20,'Position',...
[scrn_size(1)+(scrn_size(3)*shrink_pct) scrn_size(2)+(scrn_size(4)*shrink_pct)...
scrn_size(3)-(scrn_size(3)*2*shrink_pct) scrn_size(4)-(scrn_size(4)*2*shrink_pct)]); % shrinking the figure
%
ax1 = gca;
dcm_obj = datacursormode(fig1); % enable control of datatips
% set(dcm_obj,'UpdateFcn',@myupdatefcn) % this will be used to configure
% data tips
set(ax1,'fontsize',22,'Color',[0.8 0.8 0.8],'gridcolor',[1 1 1],'gridalpha',0.9) % set the axis color
% to compliment the white background
%
xlabel('Time [Day HH:MM]') % x-axis date label
hold all
grid on % grid for more contrast in the axes
end
I wrote a blog on how to produce beautiful plots in MATLAB. Check it out here:
%
1 个评论
Daniel DEKASSE
2023-9-14
atharva aalok
2021-10-17
编辑:atharva aalok
2021-10-17
Please refer the following Plotting Template:
The above is an easy to follow Beginner Friendly template.
The idea is to create Professional Standard Plots within seconds without a steep learning curve and with consistency.
It also offers a wide range of preset Color Codes (please refer the attached image for the Color Palatte)
Sample Plot:
Color Palatte:
3 个评论
atharva aalok
2021-10-18
No that's not true in most cases.
A researcher probably just wants better quality graphs without learning in depth the details of MATLAB.
The learning part is good from a long term perspective but what a beginner probably needs is a quick and easy to understand solution that gets the work done. Otherwise a steep learning curve can actually hinder growth.
Once she knows that certain things can be done then he might be interested in going into the details to customize things as per individual requirement.
Image Analyst
2021-10-18
Not true? Hmmm... interesting. So given the learning curves below (a steep one and a flatter one):
you'd prefer the flatter red one where less is learned over time, instead of the steep green one where much more is learned over the same period of time. OK, well whatever. Personally I would prefer the steeper curve, meaning I learned faster and learned more in the same period of time.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!