Scatterplot with two x and y axes only showing one dataset
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Star Strider
2022년 5월 16일
The code only creates one tile:
t = tiledlayout(1,1);
Changing it to:
t = tiledlayout(1,2);
or:
t = tiledlayout(2,1);
.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!