Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plotting question

Subject: plotting question

From: Rogelio

Date: 5 May, 2010 16:27:10

Message: 1 of 2

Hello,
I have a question, Im wondering how can I make nicer the next figure:

xval1=1:4;
xval2=5:9;
X1=[1 2^2 3^2 4^2];
X2=[17 18 18.2 18.3 18.4 ];
plot(xval1,X1)
hold on
plot(xval2,X2)
plot(xval5,X2+1,'r')
plot(xval5,X2-1,'r')

What I want is to plot some kind of a shadow from the last point of X1, 4^2, whith borders given by X2 + 1 and X2 - 1, the red lines.

X2 is the forecast of X1 and the red lines are the confidence intervals in my real example. So what I want is to make a plot with some kind of grey shadows which represents the different confidence intervals, lighters or darker depending on the level of confidence.
Thanks for any suggestion.

Subject: plotting question

From: Walter Roberson

Date: 5 May, 2010 16:37:21

Message: 2 of 2

Rogelio wrote:
> So what I want is to make a plot with some kind of
> grey shadows which represents the different confidence intervals,
> lighters or darker depending on the level of confidence.

You will need to create patch() objects in the geometry of the shadows
you want, with the FaceColor of the patch set to the shade you want.

As patches only support transparency when you are using the OpenGL
renderer, you should put the patches "behind" the lines, by using an
explicit z coordinate for them that is less than 0. Even if you _are_
using OpenGL you should do that rather than relying on transparency,
because the OpenGL rules allow it to ignore the drawing order when a
line and a surface are in the same plane; OpenGL defines the order in
that situation, but reports here have determined that some systems
reverse the order mandated by the standard. The work-around for this
OpenGL issue is to not have the surface and the line in the same plane,
by defining explicit Z coordinates for the surface...

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us