Two y axis with the same data set

조회 수: 2 (최근 30일)
Han Ju Lee
Han Ju Lee 2022년 3월 11일
편집: VBBV 2022년 3월 12일
Hi,
Just to be clear, I don't think i am asking the same question that is already abundant which is basically plotting two graphs with two axis in one graph.
But I need to plot one 2d contour plot with one dataset with two y axis on left and right side. But I am not plotting a second contour plot dependent on the second y axis but rather the 2nd yaxis is just there as a reference to different scales.
An example plot is included below. Ignore the filled gradient and focus on just line contour. This contour plot is plotted with respect to left yaxis and bottom xaxis. But it also includes secondary yaxis on the right and the secondary xaxis on top. If I just use yyaxis and plot another contour with the secondary yaxis, it will just generate a secondary contour which I don't want. I think this plot was generated using tecplot but I would like to use matlab if possible for scripting reasons. Is this possible in matlab? Thank you in advance.

채택된 답변

VBBV
VBBV 2022년 3월 12일
편집: VBBV 2022년 3월 12일
dk = 1000;
dB = linspace(0.002,dk,7)*1e-6; % in micrometer
Sg = linspace(0.001,20,7);
hold all
M = rand(7);
t = tiledlayout(1,1);
ax1 = axes(t);
contour(ax1,Sg,dB/1e-6,M);
ax1 = gca;
ax1.XScale = 'log';
ax1.YScale = 'log' ;
hold(ax1);
Current plot held
ax2 = axes(t);
contour(ax2,Sg,dB/1e-6,M);
ax2 = gca;
ax2.XScale = 'log';
ax2.YScale = 'log';
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
colorbar;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by