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:
Recession-like bar based on time period in Matlab - How?

Subject: Recession-like bar based on time period in Matlab - How?

From: sc2

Date: 9 Sep, 2010 19:24:05

Message: 1 of 3

I am trying to create a shaded bar behind my line graph. It will be
for economic data and will be used as a "credit freeze" time period
indicator(gray bars up only). This is much like a recession bar,
however it isn't when something goes below a certain level on the
graph, it is specific dates. I am new to matlab, so was wondering if
anyone could help a damsel in distress?

Thanks!

Subject: Recession-like bar based on time period in Matlab - How?

From: Sean

Date: 9 Sep, 2010 19:37:19

Message: 2 of 3

sc2 <shanacase3@gmail.com> wrote in message <c04811ae-e6c1-4574-b456-4b95f4f6e92b@y3g2000vbm.googlegroups.com>...
> I am trying to create a shaded bar behind my line graph. It will be
> for economic data and will be used as a "credit freeze" time period
> indicator(gray bars up only). This is much like a recession bar,
> however it isn't when something goes below a certain level on the
> graph, it is specific dates. I am new to matlab, so was wondering if
> anyone could help a damsel in distress?
>
> Thanks!

Could you post a picture with an example please?

Subject: Recession-like bar based on time period in Matlab - How?

From: Walter Roberson

Date: 9 Sep, 2010 19:43:11

Message: 3 of 3

On 10-09-09 02:24 PM, sc2 wrote:
> I am trying to create a shaded bar behind my line graph. It will be
> for economic data and will be used as a "credit freeze" time period
> indicator(gray bars up only). This is much like a recession bar,
> however it isn't when something goes below a certain level on the
> graph, it is specific dates. I am new to matlab, so was wondering if
> anyone could help a damsel in distress?

Probably the easiest way would be to use patch() .

If you are not using the OpenGL renderer, then you can create the patch()
object first and then the line graph to have the line graph be "on top" of the
patch. If that is inconvenient, you could use uistack() to push the patch
below the line graph.

If you _are_ using the OpenGL renderer, then due to an oddity in the way
OpenGL works (in general, not just for Matlab), no matter which order you draw
the items in, OpenGL will always create the line in a particular relationship
to a surface that is in the same plane. That isn't always the order you want
-- and although the order is documented and what you want might happen to be
the documented order, there is a problem that some implementations get the
order exactly backwards. Therefore if you are using the OpenGL renderer, then
the best thing to do is to give the patch a small negative Z so that it will
be "behind" the line graph.

You can force a particular renderer to be used. Sometimes Matlab will
automatically switch to OpenGL (if you have not told it not to); I have not
figured out the circumstances as yet.

You can determine which renderer is being used by commanding

get(gcf,'renderer')

Tags for this Thread

No tags are associated with 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