Plot shows markers, but no lines, no matter what is being plotted

조회 수: 2 (최근 30일)
Mathew
Mathew 2023년 3월 16일
댓글: Star Strider 2023년 3월 17일
Title says it all. Even for extremely simple plots copied from the official documentation, such as
x = linspace(0,10,100);
y = exp(x/10).*sin(4*x);
plot(x,y,'-o')
I get a plot which has markers but just a few whispy segments of line (see attached). I'm using 2023a in browser at https://matlab.mathworks.com/.
Edit for clarity: According to official documentation, the code above should produce a plot with lines connecting the markers. The problem is that, when I run this code, is does not do so. It has only markers, for reasons mysterious to me.
Edit for clarity: I am running this in-browser at https://matlab.mathworks.com/, using all default settings and after clearing local variables.

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 3월 16일
Here is the corrected code:
x = linspace(0,10,100);
y = exp(x/10).*sin(4*x);
scatter(x,y)
% In case, you want with lines:
x = linspace(0,10,100);
y = exp(x/10).*sin(4*x);
figure
plot(x,y, 'bo-', 'linewidth', 2)
  댓글 수: 1
Mathew
Mathew 2023년 3월 16일
편집: Mathew 2023년 3월 16일
I'm not sure in what sense that first plot is "correct code" since the problem here is that I don't have lines, but want lines, in my plot. Either way, the code you shared does not fix the issue I described in my original post. When I run it in browser, I get the attached image.

댓글을 달려면 로그인하십시오.


Star Strider
Star Strider 2023년 3월 17일
The code is also being run in R2023a, since that just released. If you are using the pre-release version, consider downloading the official release (you’ll want to do that anyway), and see if the problem persists.
Otherwise, you could be encountering a graphics rendering problem. See Resolving Low-Level Graphics Issues for details. Specifically, be sure that you’re using the latest graphics drivers.
  댓글 수: 2
Mathew
Mathew 2023년 3월 17일
> If you are using the pre-release version, consider downloading the official release
> Specifically, be sure that you’re using the latest graphics drivers.
I don't think either of these apply, as I haven't downloaded anything and am not using my own graphics drivers. I am running this in browser at https://matlab.mathworks.com/, using all default setting.
Star Strider
Star Strider 2023년 3월 17일
O.K., so you are doing this on your personal computer however using MATLAB Online.
Running your code here (I didn’t separately test it in MATLAB Online) —
x = linspace(0,10,100);
y = exp(x/10).*sin(4*x);
plot(x,y,'-o')
On my computer,. everything appears to be working correctly and all the llines and markers appear. That you are getting a different result implies to me that this could still be a graphics driver problem on your computer, since your computer has to render the plot. Alternatively, it could possibly be a browser problem, so it could be worthwhile to run your code with a different browser to see if there’s a difference. That could also help differentiate between a browser problem and a graphics driver problem.
I’m just formulating hypotheses here that you can test to see if it’s possible to identify the problem. That’s essentially all that I can do.
.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by