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

3 views (last 30 days)
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.

Answers (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 16 Mar 2023
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 Comment
Mathew
Mathew on 16 Mar 2023
Edited: Mathew on 16 Mar 2023
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.

Sign in to comment.


Star Strider
Star Strider on 17 Mar 2023
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 Comments
Mathew
Mathew on 17 Mar 2023
> 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 on 17 Mar 2023
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.
.

Sign in to comment.

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!