How to make nice plots?

270 Ansichten (letzte 30 Tage)
Sepp
Sepp am 9 Jun. 2014
Kommentiert: Daniel DEKASSE am 14 Sep. 2023
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 Kommentare
Star Strider
Star Strider am 9 Jun. 2014
How do you want it to look?
What do you want to do?
Please go into some detail.
Sepp
Sepp am 9 Jun. 2014
My question was peraps wrong. How is the standard way to include a matlab plot in latex? Just plot it as I did and then do \includegraphics in a figure environment?
I have a second problem. I want that just one single point is red and I also want a thin red vertical line at this point (ranging from the bottom to the top of the graph). How can I do that?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Kelly Kearney
Kelly Kearney am 9 Jun. 2014
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:
1) Save using export_fig; it will take care of a lot of the prettifying for you.
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 Kommentare
Kelly Kearney
Kelly Kearney am 16 Jun. 2014
@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
Star Strider am 16 Jun. 2014
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (5)

Star Strider
Star Strider am 9 Jun. 2014
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.

Image Analyst
Image Analyst am 11 Jun. 2014
  1 Kommentar
Malcolm Lidierth
Malcolm Lidierth am 11 Jun. 2014
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

Melden Sie sich an, um zu kommentieren.


Henric Rydén
Henric Rydén am 9 Jun. 2014
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')

Joshua Hrisko
Joshua Hrisko am 16 Feb. 2018
Bearbeitet: Joshua Hrisko am 16 Feb. 2018
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 Kommentar
Daniel DEKASSE
Daniel DEKASSE am 14 Sep. 2023
Thank you for the fonction that you provide, How apply it to a plot?

Melden Sie sich an, um zu kommentieren.


atharva aalok
atharva aalok am 17 Okt. 2021
Bearbeitet: atharva aalok am 17 Okt. 2021
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 Kommentare
atharva aalok
atharva aalok am 18 Okt. 2021
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
Image Analyst am 18 Okt. 2021
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Geographic Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by