Problems with the function plot
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Giulio Caforio
le 3 Oct 2017
Modifié(e) : Giulio Caforio
le 17 Oct 2022
Dear commmunity,
I have two computers with the same Matlab version(R2016b).
When I run
x=0:1:100
y=x^2
plot(x,y,'.')
in one of the two I'm not able to see the plot. The other one, instead, is able to represent the plot, so I can see all the points. Why?
2 commentaires
Jan
le 3 Oct 2017
Please explain any details: Is the monitor turn on? Is the figure created on a 2nd monitor? Does the rest of Matlab work like expected? "I do not see anything" does not allow to understand, what happens.
Réponse acceptée
OCDER
le 3 Oct 2017
Modifié(e) : OCDER
le 3 Oct 2017
NEW ANSWER
Somehow, setting to opengl renderer after Matlab starts causes an issue. I could replicate the bug if I do opengl software first, and then trying to plot. Switching the renderer to painters restores the dots.:
%Replicating the error like this: (Open MATLAB from start)
opengl software
Gx = figure;
x=0:1:100;
y=x.^2;
plot(x,y,'.') %empty, no dots are showing
set(Gx, 'renderer', 'painters'); %dots reappear
Looks like setting renderer to opengl could cause that issue. To fix, you could just set default renderer to painters via:
set(0, 'defaultFigureRenderer', 'painters')
OLD ANSWER (for the figure not showing at all)
My attempt to answer this vague problem is - one computer has set the default figure visibility to off, hence it plots but does not show anything.
To check this:
get(0, 'DefaultFigureVisible') %should be 'on'. If not, fix it.
To fix this:
set(0, 'DefaultFigureVisible', 'on')
close all %to make sure any invisible plots are closed before trying to plot again.
17 commentaires
OCDER
le 23 Oct 2017
Modifié(e) : OCDER
le 23 Oct 2017
Hi Shahzad, this might be a slightly different issue.
Instead of using painters, try opengl. If that fails, try to plot the simple
plot(1:10, 1:10, 'r') %Does this work ?
set(gcf, 'renderer', 'opengl') %Does it work now?
If this doesn't fix it, try posting this as a new question so you can get answers:
Question: Why can't I see plot lines, but other plots like histogram works?
In your description, something like:
"I'm trying to plot lines, but the lines won't show. I've tried the Q&A section described at https://www.mathworks.com/matlabcentral/answers/359509-problems-with-the-function-plot, but changing the renderer to Painters failed. Here's the code I tried:
(Use the {} Code button to make the code appear like this:)
%Plot code
x = 1:10;
y = x.^2;
plot(x, y, 'r') %NO LINES!!!
Kazi Hafizur Rahman
le 5 Oct 2020
thanks a lot,it just solved my problem I was stuck for almost two days
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Performance dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!