MATLAB Answers

How do I generate a figure that matches what is shown in MATLAB documentation?

5 views (last 30 days)
Steven
Steven on 4 Nov 2014
Commented: Steven on 5 Nov 2014
Why do the plots I generate using the example code from MATLAB documentation not look the same as those displayed in the documentation? Using waterfall plot as an example, http://www.mathworks.com/help/matlab/ref/waterfall.html, the documentation says to enter 3 simple lines of code:
figure
[X,Y,Z] = peaks(30)
waterfall(X,Y,Z)
Doing this, the figure I get looks much different than the example shown. I have compared the fig, as well as a saved jpg, png, eps, and pdf with none of them displaying like the documentation figure. Here is png shown on the documentation webpage,
and here is the png saved from MATLAB R2013b (8.2.0.701) 64-bit (glnxa64),
The 6 most significant differences I see between these two are as follows (in order of priority).
  1. An axis box blocking the view of the plot
  2. There is aliasing shown in the lines rather making jagged rather than smooth lines# The grid lines show as harsh dots instead of as light lines
  3. Extra axis ticks are displayed along only the x- and y-axis
  4. The plotted x-axis covers the range from -3 to 3 with a label at each integer instead of from -4 to 4 with a label at every even integer
  5. The show a different color gradient
My ultimate question is how do I generate a figure that actually looks the same as those shown in the documentation? Perhaps there is a simple function MATLAB programmers use for this that I am missing. Are they manually changing each one of those differences?
Further, why does the documentation not actually display what the software renders? This has not been my experience using Mathematica or Python. This is not unique to the waterfall function; I also experience this using 'surf', 'scatter3', and even the most simple 'plot'.

  1 Comment

Harry
Harry on 4 Nov 2014
If it's any consolation, I get a bit of a cross between the two:
Regarding your point number 4, note that the axis limits change as you resize the figure window. Therefore, this could be a function of your computer's screen resolution and aspect ratio.
I'm pretty sure the figure in the Matlab documentation is genuine. I imagine these things differ between platforms.

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 4 Nov 2014
Edited: the cyclist on 4 Nov 2014

I think the primary issue is the MATLAB version. In the latest version, MATLAB 2014b, MathWorks completely overhauled their graphics. I think this explains pretty much everything in your list. The online documentation naturally presents the latest version.

Here's what it looks like on my machine (with the latest version):

This page describes the new graphics in 2014b.

  1 Comment

Steven
Steven on 5 Nov 2014
This is a huge improvement. I am glad to see MathWorks make these changes. Thank you for your response.

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by