"Philip " <firstname.lastname@example.org> wrote in message <email@example.com>...
> I'm struggling with defining the axis on a bar chart. Can anybody help?
> I wish to plot a bar chart - just a single bar, but with two y-axis. The left hand y-axis will be in a percentage in the range 0 to 100 %. The right hand y-axis will be a cash amount.
> For example 50 % (left hand axis) corresponds to 12345 (right hand axis)
> h = plotyy(1:1, 0.5, 1:1, 12345, @bar, @bar);
> works perfectly.
> I would like to change the y limit to be from 0 to 100 % on the left hand axis and 0 to (12345 x 2) on the right hand axis. Can anybody help?
Just try this . It may help you
This example creates a graph to display two separate sets of data using the bottom and left sides as the x- and y-axis for one, and the top and right sides as the x- and y-axis for the other.
Suppose you have two sets of data having different x- and y-ranges:
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;
Using low-level line and axes routines allows you to superimpose objects easily. Plot the first data, making the color of the line and the corresponding x- and y-axis the same to more easily associate them.
hl1 = line(x1,y1,'Color','r');
ax1 = gca;
Next, create another axes at the same location as the first, placing the x-axis on top and the y-axis on the right. Set the axes Color to none to allow the first axes to be visible and color code the x- and y-axis to match the data.
ax2 = axes('Position',get(ax1,'Position'),...
Draw the second set of data in the same color as the x- and y-axis.
hl2 = line(x2,y2,'Color','k','Parent',ax2);