Can't plot reference line in pcolor-plot with logarithmic y-axis

29 ビュー (過去 30 日間)
Tim Hilt
Tim Hilt 2019 年 10 月 16 日
コメント済み: Tim Hilt 2019 年 10 月 16 日
I have code similar to:
h = pcolor(rand(100, 100));
h.EdgeColor = 'none';
line([30 30], [0 100], 'Color', 'red');
set(gca, 'YScale', 'log');
This should plot some random values and draw a vertical line at x = 30. When i debug the code it works until i scale the y-axis, then the line disappears.
Can anyone help me out?

採用された回答

Robert U
Robert U 2019 年 10 月 16 日
Hi TIm Hilt,
the problem is that on logarithmic scale zero is not defined thus your line does not have a valid starting point (30,0). Change the y-component to a small but non-zero value and the line reappears.
h = pcolor(rand(100, 100));
h.EdgeColor = 'none';
line([30 30], [1 100], 'Color', 'red');
set(gca, 'YScale', 'log');
Kind regards,
Robert
  1 件のコメント
Tim Hilt
Tim Hilt 2019 年 10 月 16 日
Ah ok, i got it. Thank you very much!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by