## bar same X-axis two Y axis

### bar same X-axis two Y axis

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

### bar same X-axis two Y axis

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

--
Steve Lord
XXXX@XXXXX.COM

### bar same X-axis two Y axis

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 ?

### bar same X-axis two Y axis

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

### bar same X-axis two Y axis

"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
XXXX@XXXXX.COM

### bar same X-axis two Y axis

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.

### bar same X-axis two Y axis

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

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
changing one should work.

--
Steve Lord
XXXX@XXXXX.COM

### bar same X-axis two Y axis

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

My best regards.

### bar same X-axis two Y axis

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'

### bar same X-axis two Y axis

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
XXXX@XXXXX.COM

### bar same X-axis two Y axis

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