Create a right axis which correspond to the first axis.

1 visualización (últimos 30 días)
Mac
Mac el 9 de Mayo de 2022
Comentada: Mac el 10 de Mayo de 2022
Hello guys. Badly need help. I have a wavenumber-frequency plot. I would like to add a right axis, but in period (1/frequency). Please help with the command. Below is my sample plot. Thank you very much.
  2 comentarios
Mac
Mac el 9 de Mayo de 2022
Thanks mate. This (link) shows plotting different data. Mine is the same data but I want the right axis to be in period (1/f). Thank you mate.

Iniciar sesión para comentar.

Respuesta aceptada

Chunru
Chunru el 9 de Mayo de 2022
Editada: Chunru el 9 de Mayo de 2022
freq = [1000:10:5000];
wn = [-1.5:0.01:1.5];
p = 1./freq;
h1= axes;
data = randn(length(freq), length(wn));
imagesc(wn, freq, data);
axis xy
% create another axes with same position
% h2 = axes('Position', h1.Position, 'Color', 'none', 'YLim', h1.YLim, 'XTick', [], ...
% 'YAxisLocation', 'right', 'YTickLabel', sprintf('%.2e\n', 1./h1.YTick), 'FontSize', 8);
rightytick = [2.5 3 4]*1e-4;
rightytick = flip(rightytick);
h2 = axes('Position', h1.Position, 'Color', 'none', 'YLim', h1.YLim, 'XTick', [], ...
'YAxisLocation', 'right', ...
'YTick', 1./rightytick, 'YTickLabel', sprintf('%.2e\n', rightytick), 'FontSize', 8);
  3 comentarios
Mac
Mac el 10 de Mayo de 2022
Thank you very much.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by