The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Is it possible to specify certain plotting properties when using plotyy()?
Replies: 5   Last Post: Nov 21, 2013 2:08 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Kate J.

Posts: 177
Registered: 6/9/11
Re: Is it possible to specify certain plotting properties when using plotyy()?
Posted: Nov 19, 2013 2:10 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I made some progress, and now have the axes correctly labeled. However, I'm still encountering the problem of not being able to correctly specify the axes limits. Below is my full script & a description of the specific problem:

x_set1 = [1 2];
x_set2 = [3 4];
x_set3 = [5 6];
x_set4 = [7 8];
x_set5 = [9 10];

S1_data_subset1 = [-0.18 -0.18];
S1_data_subset2 = [-0.42 -0.38];
S1_data_subset3 = [-0.42 -0.44];
S1_data_subset4 = [-0.42 -0.48];
S1_data_subset5 = [-0.60 -0.72];

x_learning = [1.5 3.5 5.5 7.5 9.5];
S1_learning = [19 1 1 9 1];

x_learning1 = [1.5];
x_learning2 = [3.5];
x_learning3 = [5.5];
x_learning4 = [7.5];
x_learning5 = [9.5];

S1_learning1 = [19];
S1_learning2 = [1];
S1_learning3 = [1];
S1_learning4 = [9];
S1_learning5 = [1];

M1 = [x_set1, NaN, x_set2, NaN, x_set3, NaN, x_set4, NaN, x_set5, NaN];
M2 = [x_learning1, NaN, x_learning2, NaN, x_learning3, NaN, x_learning4, NaN, x_learning5, NaN];
Y1 = [S1_data_subset1, NaN, S1_data_subset2, NaN, S1_data_subset3, NaN, S1_data_subset4, NaN, S1_data_subset5, NaN];
Y2 = [S1_learning1, NaN, S1_learning2, NaN, S1_learning3, NaN, S1_learning4, NaN, S1_learning5, NaN];
[AX, H1, H2] = plotyy(M1, Y1, M2, Y2);

set(get(AX(1),'Ylabel'),'String','Mean Value','FontSize',14,'FontWeight','bold');
set(get(AX(2),'Ylabel'),'String','Net Change (%)','FontSize',14,'FontWeight','bold');

% If I use this, the left Y axis becomes extremely compacted...
% ylim([-2 2]);

If I adjust the left Y axis using the Ylim() function, instead of having these [-2, 2] values span the entire left Y axis, these values are instead compacted (and interestingly, these left-Y-axis values do not at all match up with the right Y axis scale's values). Again, as I mentioned in my previous post above, using Edit --> Axes properties only affects the left Y axis, and accomplishes the same incorrect change as calling ylim().

To summarize, I'd like my left Y axis to have limits of [-2,2] (without being squished into a small area of this axis) and the right Y axis to have limits of [-20,20]. And I want my 2nd data set to have substantial markers so that the plotted values are visible, instead of being single pixels. Thanks for your suggestions.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2017. All Rights Reserved.