Setting additional specific axis tick marks
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I have a y axis that spans 0 - 15. I want to place an extra tick mark (labelled with its value) at the minimum value of y (0.018 in one data set, for example).
It is not appropriate for me to use a log scale - the data is well presented, it is just not obvious to the reader that the minimum value is not zero.
Thank you.
採用された回答
Walter Roberson
2011 年 6 月 16 日
set(gca, 'YTick', sort([0.018, get(gca, 'YTick')]));
9 件のコメント
Etienne O'Brien
2011 年 6 月 16 日
Thank you Walter. Now the 0.018 value is sitting on top of the '0' label of the y axis so both values are hard to read. Is it possible to remove the default'0' value so that the axis starts 0.018 then continues as specified by default? In this example the other labels on the graph (specified by default) are 5, 10 , 15 - I'd like to be able to generalize to other graphs too.
Walter Roberson
2011 年 6 月 16 日
ytick = get(gca, 'YTick');
ytick(1) = 0.018;
set(gca, 'YTick', ytick);
Walter Roberson
2011 年 6 月 16 日
Alternative in one line:
set(gca, 'YTick', max(0.018, get(gca, 'YTick')));
Etienne O'Brien
2011 年 6 月 16 日
Thank you Walter.
Tiezheng Song
2017 年 3 月 19 日
This is awesome
Erik Lundgren
2017 年 12 月 23 日
編集済み: Erik Lundgren
2017 年 12 月 23 日
set(gca, 'YTick', max(0.018, get(gca, 'YTick'))); <-- Wonderful! Thanks Walter!
set(gca, 'YTick', unique([0.018, get(gca, 'YTick')]));
Using unique instead of sort prevents an error is the added tick was already there
Jafar Habshee
2019 年 5 月 8 日
How can the label be added in similar fasion?
Walter Roberson
2019 年 5 月 8 日
After setting the YTick, you can pull out the YTick again and format the values and send those to the YTickLabels property.
With R2014b or later you would typically only do that if you had special formatting needs, such as needing one label to look different than the others, or if you wanted to convert each value to its multiple of Pi : for plain formatting issues you would instead set the axes YAxis.TickLabelFormat property.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Grid Lines, Tick Values, and Labels についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
