Scatterplot with two x and y axes only showing one dataset

1 vue (au cours des 30 derniers jours)
Kimberly Sauceda
Kimberly Sauceda le 16 Mai 2022
t = tiledlayout(1,1);
ax1 = axes(t);
scatter(ax1,Data{:,1},Data{:,7});
hold on
ax1.XColor = 'b';
ax1.YColor = 'b';
ylabel({'Isoprene (ppbv)'});
set(gca, 'XTick', Time(1:40:end));
datetick('x','mm/dd HH:MM:SS','keepticks');
xtickangle(90);
tstart=datenum(2021,9,6,00,00,00);
tend=datenum(2021,9,7,00,00,00);
xlim([tstart tend]);
hold off
ax2 = axes(t);
scatter(ax2,Data{:,1},Data{:,9});
hold on
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
ax2.XColor = 'r';
ax2.YColor = 'r';
ax1.Box = 'off';
ax2.Box = 'off';
ylabel({'MEK (ppbv)'});
set(gca, 'XTick', Time(1:40:end));
datetick('x','mm/dd HH:MM:SS','keepticks');
xtickangle(90);
xlim([tstart tend]);
legend(gca,'show');
hold off
I am trying to plot a scatter plot with two x and y axes. The above is my code and I am not sure why but it is only plotting the second data set. When I show the legend only the MEK is shown. How do I get both axes to show at the same time?

Réponses (1)

Star Strider
Star Strider le 16 Mai 2022
The code only creates one tile:
t = tiledlayout(1,1);
Changing it to:
t = tiledlayout(1,2);
or:
t = tiledlayout(2,1);
and a nexttile call, the other one will also plotted.
.

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by