Thread Subject: bar same X-axis two Y axis

Subject: bar same X-axis two Y axis

From: Et'o Pat

Date: 30 Dec, 2008 20:51:04

Message: 1 of 11

I have two sets of data of different scales. From which I try draw a double bar chart. Because of the problem of differents scales, only one bar can be seen in the figure. One solution can be to normalized the data with large scale, but I wish to plot the bar with their real scales.

Can you help me to draw a multi-bar with the same X-axis and two-Y axis such that the scale of the first Y-axis is for the first bar and the scale of the second one corresponds to the second bar.

Thanks

Subject: bar same X-axis two Y axis

From: Steven Lord

Date: 31 Dec, 2008 05:33:51

Message: 2 of 11


"Et'o Pat" <patmbom@hotmail.com> wrote in message
news:gje1jo$4p4$1@fred.mathworks.com...
>I have two sets of data of different scales. From which I try draw a double
>bar chart. Because of the problem of differents scales, only one bar can
>be seen in the figure. One solution can be to normalized the data with
>large scale, but I wish to plot the bar with their real scales.
>
> Can you help me to draw a multi-bar with the same X-axis and two-Y axis
> such that the scale of the first Y-axis is for the first bar and the scale
> of the second one corresponds to the second bar.

Use the five- or six-input form of PLOTYY, specifying BAR as the function to
use to plot on each axes.

--
Steve Lord
slord@mathworks.com

Subject: bar same X-axis two Y axis

From: Et'o Pat

Date: 31 Dec, 2008 07:28:06

Message: 3 of 11

Stev, Thanks for you quick answer.
I'm not very good in informatic. Can you give write the code which allow to draw the graph ?




"Steven Lord" <slord@mathworks.com> wrote in message <gjf07v$3kc$1@fred.mathworks.com>...
>
> "Et'o Pat" <patmbom@hotmail.com> wrote in message
> news:gje1jo$4p4$1@fred.mathworks.com...
> >I have two sets of data of different scales. From which I try draw a double
> >bar chart. Because of the problem of differents scales, only one bar can
> >be seen in the figure. One solution can be to normalized the data with
> >large scale, but I wish to plot the bar with their real scales.
> >
> > Can you help me to draw a multi-bar with the same X-axis and two-Y axis
> > such that the scale of the first Y-axis is for the first bar and the scale
> > of the second one corresponds to the second bar.
>
> Use the five- or six-input form of PLOTYY, specifying BAR as the function to
> use to plot on each axes.
>
> --
> Steve Lord
> slord@mathworks.com
>

Subject: bar same X-axis two Y axis

From: Et'o Pat

Date: 31 Dec, 2008 08:00:09

Message: 4 of 11

I have used this syntax,
plotyy(x1, s, per,z, @bar, @bar),

but an other problem occurs: both bars overlaped. How two separate them ?

My best regard


"Steven Lord" <slord@mathworks.com> wrote in message <gjf07v$3kc$1@fred.mathworks.com>...
>
> "Et'o Pat" <patmbom@hotmail.com> wrote in message
> news:gje1jo$4p4$1@fred.mathworks.com...
> >I have two sets of data of different scales. From which I try draw a double
> >bar chart. Because of the problem of differents scales, only one bar can
> >be seen in the figure. One solution can be to normalized the data with
> >large scale, but I wish to plot the bar with their real scales.
> >
> > Can you help me to draw a multi-bar with the same X-axis and two-Y axis
> > such that the scale of the first Y-axis is for the first bar and the scale
> > of the second one corresponds to the second bar.
>
> Use the five- or six-input form of PLOTYY, specifying BAR as the function to
> use to plot on each axes.
>
> --
> Steve Lord
> slord@mathworks.com
>

Subject: bar same X-axis two Y axis

From: Steven Lord

Date: 2 Jan, 2009 19:32:52

Message: 5 of 11


"Et'o Pat" <patmbom@hotmail.com> wrote in message
news:gjf8q9$cfm$1@fred.mathworks.com...
>I have used this syntax,
> plotyy(x1, s, per,z, @bar, @bar),
>
> but an other problem occurs: both bars overlaped. How two separate them
> ?

Your message said, in part:

"Can you help me to draw a multi-bar with the same X-axis and two-Y axis "

If x1 and per overlap, so will the bars they plot (because they will be
using the same X axis.) You may want to write the calls to BAR as anonymous
functions, and specify the width parameter to make the bars narrower.

f1 = @(x, y) bar(x, y, 0.4);
f2 = @(x, y) bar(x, y, 0.3); % even narrower
plotyy(x1, s, per, z, f1, f2);

*snip the rest*

--
Steve Lord
slord@mathworks.com

Subject: bar same X-axis two Y axis

From: Et'o Pat

Date: 3 Jan, 2009 04:21:02

Message: 6 of 11

Thanks Steve and receives my best wish for the new year.

The problem of scales is overcame now, but it remains two lasts problems.

First, both bars have the same color. How to select the blue color for example for the first bar, and the red color for the second bar ?

Second, the X-axis has undesirable limit, I have tried to resolve this by using the code Xlimit([-1, 31]), unfortunately, without sucess. How to resolve this problem?

My best regards
Pat.



"Steven Lord" <slord@mathworks.com> wrote in message <gjlq54$9dp$1@fred.mathworks.com>...
>
> "Et'o Pat" <patmbom@hotmail.com> wrote in message
> news:gjf8q9$cfm$1@fred.mathworks.com...
> >I have used this syntax,
> > plotyy(x1, s, per,z, @bar, @bar),
> >
> > but an other problem occurs: both bars overlaped. How two separate them
> > ?
>
> Your message said, in part:
>
> "Can you help me to draw a multi-bar with the same X-axis and two-Y axis "
>
> If x1 and per overlap, so will the bars they plot (because they will be
> using the same X axis.) You may want to write the calls to BAR as anonymous
> functions, and specify the width parameter to make the bars narrower.
>
> f1 = @(x, y) bar(x, y, 0.4);
> f2 = @(x, y) bar(x, y, 0.3); % even narrower
> plotyy(x1, s, per, z, f1, f2);
>
> *snip the rest*
>
> --
> Steve Lord
> slord@mathworks.com
>

Subject: bar same X-axis two Y axis

From: Steven Lord

Date: 5 Jan, 2009 04:12:21

Message: 7 of 11


"Et'o Pat" <patmbom@hotmail.com> wrote in message
news:gjmp3e$gea$1@fred.mathworks.com...
> Thanks Steve and receives my best wish for the new year.
>
> The problem of scales is overcame now, but it remains two lasts problems.
>
> First, both bars have the same color. How to select the blue color for
> example for the first bar, and the red color for the second bar ?

Use the LINESPEC option for BAR or call PLOTYY with three outputs and SET
the appropriate *Color properties for the second or third handles.

> Second, the X-axis has undesirable limit, I have tried to resolve this by
> using the code Xlimit([-1, 31]), unfortunately, without sucess. How to
> resolve this problem?

You would need to use XLIM (or SET the XLimit property) for both the axes
whose handles are returned as the first output of PLOTYY in order to change
the X limits for both the left- and right-hand axes (and to keep them
synchronized.) Alternately, linking them (using LINKAXES or LINKPROP) and
changing one should work.

--
Steve Lord
slord@mathworks.com

Subject: bar same X-axis two Y axis

From: Et'o Pat

Date: 5 Jan, 2009 07:11:06

Message: 8 of 11

Thank you very much Steve. My problem is okay now!!!

My best regards.



"Steven Lord" <slord@mathworks.com> wrote in message <gjs1b5$9bn$1@fred.mathworks.com>...
>
> "Et'o Pat" <patmbom@hotmail.com> wrote in message
> news:gjmp3e$gea$1@fred.mathworks.com...
> > Thanks Steve and receives my best wish for the new year.
> >
> > The problem of scales is overcame now, but it remains two lasts problems.
> >
> > First, both bars have the same color. How to select the blue color for
> > example for the first bar, and the red color for the second bar ?
>
> Use the LINESPEC option for BAR or call PLOTYY with three outputs and SET
> the appropriate *Color properties for the second or third handles.
>
> > Second, the X-axis has undesirable limit, I have tried to resolve this by
> > using the code Xlimit([-1, 31]), unfortunately, without sucess. How to
> > resolve this problem?
>
> You would need to use XLIM (or SET the XLimit property) for both the axes
> whose handles are returned as the first output of PLOTYY in order to change
> the X limits for both the left- and right-hand axes (and to keep them
> synchronized.) Alternately, linking them (using LINKAXES or LINKPROP) and
> changing one should work.
>
> --
> Steve Lord
> slord@mathworks.com
>

Subject: bar same X-axis two Y axis

From: Et'o Pat

Date: 5 Jan, 2009 08:38:04

Message: 9 of 11

I think, I celebrated the end of this program before.

Right now my code answer to several of my questions. But it remains only one problem: the lengend.

I tried to set up the legend by using the code: legend('chacoal', 'trace') but only chacoal appears on the legend (so the legend doesn't display ' trace ' ) when I run my program.

How to set up the code of the lengend so that it displays both : 'chacoal' and 'trace'

Receives my best regards .


"Et'o Pat" <patmbom@hotmail.com> wrote in message <gjsbqa$4sl$1@fred.mathworks.com>...
> Thank you very much Steve. My problem is okay now!!!
>
> My best regards.
>
>
>
> "Steven Lord" <slord@mathworks.com> wrote in message <gjs1b5$9bn$1@fred.mathworks.com>...
> >
> > "Et'o Pat" <patmbom@hotmail.com> wrote in message
> > news:gjmp3e$gea$1@fred.mathworks.com...
> > > Thanks Steve and receives my best wish for the new year.
> > >
> > > The problem of scales is overcame now, but it remains two lasts problems.
> > >
> > > First, both bars have the same color. How to select the blue color for
> > > example for the first bar, and the red color for the second bar ?
> >
> > Use the LINESPEC option for BAR or call PLOTYY with three outputs and SET
> > the appropriate *Color properties for the second or third handles.
> >
> > > Second, the X-axis has undesirable limit, I have tried to resolve this by
> > > using the code Xlimit([-1, 31]), unfortunately, without sucess. How to
> > > resolve this problem?
> >
> > You would need to use XLIM (or SET the XLimit property) for both the axes
> > whose handles are returned as the first output of PLOTYY in order to change
> > the X limits for both the left- and right-hand axes (and to keep them
> > synchronized.) Alternately, linking them (using LINKAXES or LINKPROP) and
> > changing one should work.
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> >

Subject: bar same X-axis two Y axis

From: Steven Lord

Date: 5 Jan, 2009 14:53:04

Message: 10 of 11


"Et'o Pat" <patmbom@hotmail.com> wrote in message
news:gjsgtb$pk6$1@fred.mathworks.com...
>I think, I celebrated the end of this program before.
>
> Right now my code answer to several of my questions. But it remains only
> one problem: the lengend.
>
> I tried to set up the legend by using the code: legend('chacoal',
> 'trace') but only chacoal appears on the legend (so the legend doesn't
> display ' trace ' ) when I run my program.
>
> How to set up the code of the lengend so that it displays both : 'chacoal'
> and 'trace'

Call PLOTYY with three output arguments, combine the last two (the handles
to the lines etc. in the plot) into a vector, and call LEGEND with that
vector as the first input. This is the syntax "legend(h, ...)" given in
HELP LEGEND.

--
Steve Lord
slord@mathworks.com

Subject: bar same X-axis two Y axis

From: Et'o Pat

Date: 5 Jan, 2009 16:18:02

Message: 11 of 11

Thank you very much Steve. I'm okay now.


"Steven Lord" <slord@mathworks.com> wrote in message <gjt6sg$9j6$1@fred.mathworks.com>...
>
> "Et'o Pat" <patmbom@hotmail.com> wrote in message
> news:gjsgtb$pk6$1@fred.mathworks.com...
> >I think, I celebrated the end of this program before.
> >
> > Right now my code answer to several of my questions. But it remains only
> > one problem: the lengend.
> >
> > I tried to set up the legend by using the code: legend('chacoal',
> > 'trace') but only chacoal appears on the legend (so the legend doesn't
> > display ' trace ' ) when I run my program.
> >
> > How to set up the code of the lengend so that it displays both : 'chacoal'
> > and 'trace'
>
> Call PLOTYY with three output arguments, combine the last two (the handles
> to the lines etc. in the plot) into a vector, and call LEGEND with that
> vector as the first input. This is the syntax "legend(h, ...)" given in
> HELP LEGEND.
>
> --
> Steve Lord
> slord@mathworks.com
>

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com