Strange behaviour of plot
古いコメントを表示
When I do the following plot in R2025a, I do not see the line. (Here the code runs under R2024b)
plot([0,eps,1],[0,eps,1])
採用された回答
その他の回答 (1 件)
John D'Errico
2025 年 6 月 11 日
編集済み: John D'Errico
2025 年 6 月 11 日
Cute. If you try this in R2025a:
small = 1e-7;plot([0,small,1],[0,small,1])
small = 1e-8;plot([0,small,1],[0,small,1])
(Sorry that Answers is still seemingly broken, not executing code.)
When done using my own copy of R2025a, the first plot shows the expected diagonal line, whereas the second is a blank figure.
Even more interesting, is if I try this:
small = 1e-8;
plot([0 small 1 1+small 2],[0 small 1 1+small 2])
the plot does contain a diagonal line, but it starts at 1, not 0.
Its worth reporting to TMW as a bug.
7 件のコメント
John D'Errico
2025 年 6 月 11 日
I've posted this as a bug report, so you do not need to do so also.
Adam Danz
2025 年 6 月 11 日
Thanks for reporting!
Walter Roberson
2025 年 6 月 11 日
I do not get a blank figure; I get one that is partly drawn.

Paul
2025 年 6 月 13 日
Can you explain what the issue is for @John D'Errico's and @Walter Roberson's examples? I don't see how they relate to LineWidth or monitor resolution.
Walter Roberson
2025 年 6 月 14 日
The default line width is 0.5, and the default units is "points", which are 1/72 of an inch. But the behaviour is triggered if the line width is more than one physical pixel.
My display happens to be 5120 x 2880, and MATLAB is mapping it to 2560 x 1440.
On my system, the problem shows up when LineWidth of (strictly greater than) 0.375 is used; 0.375 or smaller LineWidth shows up as a single solid line.
0.375 / 0.5 * (5120/2560) = 1.5 pixels. speculation it might be rounding "half towards zero" so getting 1 pixel, whereas for anything greater than 0.375 would result in a value greater than 1.5 which is being rounded to 2 physical pixels or more.
Paul
2025 年 6 月 14 日
I'm still not getting it.
small = 1e-7;plot([0,small,1],[0,small,1])
small = 1e-8;plot([0,small,1],[0,small,1])
The first one worked and the second didn't. But shouldn't they both be plotting with the same DefaultLineWidth? So either both should work or neither?
And these commands
small = 1e-8;
plot([0 small 1 1+small 2],[0 small 1 1+small 2])
resulted in half of a line? Does that imply that different parts of the line use different LineWidth?
My sense from the start of this thread is that somehow the issue was related to the use of eps (as with the OP) or "small" as in this Answer thread, but I don't see how the values in the input data to plot() can influence the LineWidth.
Ray
2025 年 6 月 17 日
I think the issue here is due to the precision. For the wide line rendering, the generated line join geometry (see Line - Chart line appearance and behavior - MATLAB: LineJoin for details) might be affected/degenerated under a certain precision. This explains why two values can have different results.
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
