Problem with plotting with 3 different y axes

2 visualizzazioni (ultimi 30 giorni)
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
x = 19×1 datetime array
15-Dec-1998 07-Dec-1999 30-Nov-2000 13-Nov-2001 30-Dec-2002 04-Jan-2004 22-Nov-2004 24-Nov-2005 15-Dec-2006 22-Jan-2008 22-Jan-2009 22-Jan-2010 22-Jan-2011 22-Jan-2012 09-Jan-2013 05-Jan-2014 31-Jan-2015 31-Jan-2016 31-Jan-2017
y1=giulia_year.Diff_Values
y1 = 19×1
NaN 49.8592 -0.4379 5.5708 60.9202 32.7120 11.9641 85.5252 15.5492 6.3269
y2=giulia_year.year_values_wind
y2 = 19×1
10.0999 11.2257 8.2535 11.6761 13.6418 10.5961 11.7224 11.0361 9.3854 11.6265
y3=giulia_year.year_values_hum
y3 = 19×1
59.7365 57.2549 55.7660 52.5581 51.6366 50.1699 54.3775 58.6254 59.2755 55.5342
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','%')
Unrecognized function or variable 'plotyyy'.
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.

Risposta accettata

Dave B
Dave B il 29 Ott 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})

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by