Problem with plotting with 3 different y axes
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone,
I tried to plot this with three different y axes, but I don't get the plot.
load('giulia_year')
x=giulia_year.DateA
y1=giulia_year.Diff_Values
y2=giulia_year.year_values_wind
y3=giulia_year.year_values_hum
ylabels{1}='mm w.e.';
ylabels{2}='knt';
ylabels{3}='%';
[ax,hlines] = plotyyy(giulia_year.DateA,giulia_year.Diff_Values,giulia_year.DateA,giulia_year.year_values_wind,giulia_year.DateA,giulia_year.year_values_hum,'mm.w.e.','knt','%')
egend(hlines, 'y = giulia_year.Diff_Values','y = giulia_year.year_values_wind','y = giulia_year.year_values_hum',2)
Can anyone help me please?
Thank you.
0 Kommentare
Akzeptierte Antwort
Dave B
am 29 Okt. 2021
Unfortunately there is no plotyyy, nor is there a more-than-2 version of plotyy's succesor yyaxis.
You can kind of fake it on recent releases (I think this will work beginning in R2020b, but tested it in R2021a) with tiledlayout:
load('giulia_year')
x=giulia_year.DateA;
y1=giulia_year.Diff_Values;
y2=giulia_year.year_values_wind;
y3=giulia_year.year_values_hum;
ylabels{1}='mm w.e.';
ylabels{2}='knt';
ylabels{3}='%';
%%
t=tiledlayout(1,1,'TileSpacing','tight');
ax=axes(t);
yyaxis left
plot(x,y1)
ylabel(ylabels{1})
yyaxis right
plot(x,y2)
ylabel(ylabels{2})
% Use a second axes
ax2=axes(t);
h=plot(ax2,x,y3,'SeriesIndex',3);
ax2.Visible='off';
% Now use a third axes for the y axis for the third plot
% Put it in the west tile, and use a DataAspectRatio that
% makes it narrow
ax2_axis=axes(t);
ax2_axis.Layout.Tile='west';
ax2_axis.YColor=h.Color;
ax2_axis.DataAspectRatio=[1 eps 1];
% This tries to link up axes limits. Interactively panning the
% axes might not work work exactly as expected...(but not horrible
% either)
linkaxes([ax2 ax2_axis],'y')
linkaxes([ax ax2],'x')
ylabel(ylabels{3})
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!