Scatterplot with two x and y axes only showing one dataset
1 view (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Star Strider
on 16 May 2022
The code only creates one tile:
t = tiledlayout(1,1);
Changing it to:
t = tiledlayout(1,2);
or:
t = tiledlayout(2,1);
.
0 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!