Superimpose a curve on a a image generated by 'imagesc' command, I need to keep two different Y-axis.

3 ビュー (過去 30 日間)
prasad
prasad 2013 年 12 月 29 日
回答済み: Raghava S N 2024 年 10 月 3 日
First, I have generated a image plot using the the command 'imagesc' with a data matrix 'A'. I have fixed the Y-axis limits (as it is needed).
Now I have to plot a curve (t) on the same image plot with same X-axis but different Y-axis scale.
Requirement is, the Y-axis corresponding to the image plot should be on left side and the Y-axis corresponding to the curve should be on right side.
>>imagesc(x,y,A); hold on; plot (x,t);
Please give suggestions how to handle axis in this case ?
Thank you ......

回答 (1 件)

Raghava S N
Raghava S N 2024 年 10 月 3 日
Hi prasad,
To create plots with two y-axes, you can make use of the “yyaxis” function in MATLAB. Refer to this link for more information on the “yyaxis” function - https://www.mathworks.com/help/matlab/ref/yyaxis.html.
Use the following lines of code in your script to have the Y-axis corresponding to the image on the left side of the plot and the Y-axis corresponding to the curve on the right side of the plot
imagesc(x, y, A);
hold on;
yyaxis left;
ylabel('Image Y-axis');
% Plot the curve with a different y-axis scale
yyaxis right;
plot(x, t)
ylabel('Curve Y-axis');

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by