I plot data using plotyy, then after adding several other data series to the plot, i need to readjust the axis limits to have them all in range, but when I do, the limits only occupy a small portion of the plot as seen in the image

3 vues (au cours des 30 derniers jours)
The image below shows the problem that I am getting. When i submit the code to change the axis limit for x, there is no issue with the graph, but when i send the code to adjust the left y axis, it shrinks the size as shown below. The data is in the range, but it does not get spread out amongst the full plot area. Any ideas?
Heres the code I use to adjust the axis:
%Plot both axis's
[hax, h(1,i), h(2,i)] = plotyy(X_Data(:,i), Y1_Data(:,i), X_Data(:,i), Y2_Data(:,i));
%Set line color and marker
set(h(1,i), 'marker', 'o');
set(h(1,i), 'color', ColorSet(i,:));
set(h(2,i), 'marker', 'x');
set(h(2,i), 'color', ColorSet((ColorVariation - i),:));
%Set axis limits
xlim(hax(1), [xmin xmax])
xlim(hax(2), [xmin xmax])
ylim(hax(1), [y1min y1max])
After running this initial data, I add additional plots to the same one to have for example 5 lines corresponding to the left y axis and the right y axis. But I need to be able to adjust the limits to see the data accordingly. Thanks!
  3 commentaires
Abhisek Roy
Abhisek Roy le 4 Fév 2016
Hi Ryan,
It looks like at some point in the code the 'XTick' for 'hax(1)' is set as [3.75 3.8 3.85 3.9 3.95] as those are the only ticks which are being marked in the plot and also from the figure, I noticed that the first plot(hax(1)) i.e. the blue plot is spanned through-out the plot window. So, I think in the code somewhere XTicks are defined. Is this the complete code which is giving you the above plot?
dpb
dpb le 4 Fév 2016
Good catch @Abhisek...also note that while the code snippet says
set(h(1,i), 'marker', 'o');
set(h(2,i), 'marker', 'x');
that the actual markers are reversed from what one would expect given the plotyy call
[hax, h(1,i), h(2,i)] = plotyy(...
the column 1 line handles should be associated with the LH axis and vice versa but by the axis color they're reversed. Things have gotten jumbled, clearly.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Two y-axis dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by