How to add a right hand y-axis with the same major and minor ticks?

29 ビュー (過去 30 日間)
Leon
Leon 2022 年 1 月 24 日
回答済み: Kenneth Casperson 2022 年 2 月 17 日
My goal is to add two y-axis of the same major and minor ticks. Their color should all be black.
Here is my current code to do it for the left hand axis:
set(han01, 'yTick', [1:0.5:4]);
set(han01,'XMinorTick','on','YMinorTick','on')
How do I add the same axis to the right side?
Many thanks!

採用された回答

G A
G A 2022 年 1 月 24 日
編集済み: G A 2022 年 1 月 24 日
x = -2*pi:0.1:2*pi;
y1 = sin(x);
y2 = tan(x);
yyaxis left
hp1 = plot(x,y1);
h1 = gca;
h1.YTick = -1:0.5:1;
set(h1,'XMinorTick','on','YMinorTick','on');
box on
h1.YColor = 'k';
h1.YLim = [-1.1, 1.1];
yyaxis right
hp2 = plot(x,y2);
h2 = gca;
h2.YTick = -1:0.5:1;
set(h2,'YMinorTick','on');
h2.YColor = 'k';
h2.YLim = [-1.1, 1.1];
  2 件のコメント
Leon
Leon 2022 年 1 月 24 日
Excellent! This works great.
Many thanks for your help.
G A
G A 2022 年 1 月 24 日
You are welcome

サインインしてコメントする。

その他の回答 (1 件)

Kenneth Casperson
Kenneth Casperson 2022 年 2 月 17 日
Different answers are questioned by the experts. The centre of the https://www.aussiessay.com/coursework-help.php are held for the goals. The value is done for the approval of the turns and techniques in the mid of the filed moves for all issues.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by