Two y axis with the same data set

33 views (last 30 days)
Han Ju Lee
Han Ju Lee on 11 Mar 2022
Edited: VBBV on 12 Mar 2022
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.

Accepted Answer

VBBV
VBBV on 12 Mar 2022
Edited: VBBV on 12 Mar 2022
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;

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!