How to replace x or y axis tick values with texts

48 ビュー (過去 30 日間)
Nayeem Iftekher
Nayeem Iftekher 2021 年 3 月 4 日
コメント済み: Nayeem Iftekher 2021 年 3 月 4 日
I want to replace my yaxis tick values with texts.
x=[1,3,4,6]; y=[20,40,50,80]; Plot(x,y);
For this, I want to replace the ytick values with white, red, green, yellow instead of 20,40,50,80 respectively.

採用された回答

Walter Roberson
Walter Roberson 2021 年 3 月 4 日
編集済み: Walter Roberson 2021 年 3 月 4 日
x=[1,3,4,6]; y=[20,40,50,80]; plot(x,y);
yticks([20,40,60,80])
yticklabels({'white', '\color{red}red', '\color{green}green', 'yellow'}); set(gca,'TickLabelInterpreter', 'tex')
ycat = categorical(y, [20 40 50 80], {'white', 'red', 'green', 'yellow'})
ycat = 1×4 categorical array
white red green yellow
plot(x, ycat)
  1 件のコメント
Nayeem Iftekher
Nayeem Iftekher 2021 年 3 月 4 日
Thank you very much @walter

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by