Problems with the function plot
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
Jan
2017년 10월 3일
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.
Sorry Jan for my inaccuracy. I mean: I run the the mini program that I wrote before but the graph is completely white. If I change (for example from '.' to '*'), I will see the graph with the asterisks, but I do not see anything with the points
채택된 답변
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
Hi Donald, thank you for your answer. I have just checked what you said, and the variable 'ans' is 'on', so I closed Matlab and I re-opened it. I run the the mini program that I wrote before but the graph is completely white. If I change (for example from '.' to '*'), I will see the graph with the asterisks, but I do not see anything with the points
OCDER
2017년 10월 3일
So does the plot show now, at least with '*' ? I guess I misread your question (hence details would be nice!). When you said you "did not see anything", it sounds like you "do not see any figure of a plot". This is a different issue where you cannot see the dots on the plot. Send us a screenshot, the exact code you used, and we might be able to figure it out with enough information.
Giulio Caforio
2017년 10월 3일
편집: Walter Roberson
2017년 10월 3일
Certainly:
the code is:
x=0:1:100;
y=x.^2;
plot(x,y,'.')
Try giving the command
opengl software
and then plotting.
Also, try
h = plot(x,y,'.');
get(h, 'MarkerSize')
get(h, 'MarkerColor')
Hi Walter, thank you for your answer: I tried, nothing.
OCDER
2017년 10월 3일
Can you show us the image with the '*' option? Just trying to see if that's small and what color it defaults to.
Interesting... It does everything it should, except for the dots. This could be a bug, some kind of issue with the renderer and video card. Last effort, try:
Gx = figure;
set(Gx, 'Renderer', 'painters')
x=0:1:100;
y=x.^2;
plot(x,y,'.')
If this doesn't work, might have to ask MathWorks directly via the bug reporting system.
What was the result of
get(h, 'MarkerSize')
get(h, 'MarkerColor')
Whoa, I just replicated that bug.
%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')
This does not appear to happen on OS-X for R2017b -- which does not support software opengl.
Thank you Donald. I do not understand very well how you solved the problem, but if I write:
Gx = figure;
x=0:1:100;
y=x.^2;
plot(x,y,'.')
set(Gx, 'renderer', 'painters');
I will see all the points.So, Must I write always this function set(Gx, 'renderer', 'painters') to see the points? Does a final function exist to set definitively this option?
I'm not quite sure how to permanently set the renderer to 'painters', but you could do
set(0, 'defaultFigureRenderer', 'painters')
once per each new session of matlab. That way, any new plots you draw will automatically use the painters renderer.
Even better, if you open MATLAB via a shortcut icon in your desktop, reset the shortcut path to something like this:
some_path_to_matlab/matlab.exe -r "set(0, 'DefaultFigureRenderer', 'painters')"
This way, everytime you open MATLAB, it will apply the default renderer for you without you having to worry about it.
shahzad muhammad
2017년 10월 22일
almost, same problem with me, using MATLAB 2015a. I try to fixed it by above discussion but failed. figure is shown but plot line is not shown. this is specially for plot command rest of all plot types like area, histogram, etc. working good. please, help me.
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!!!
thanks a lot,it just solved my problem I was stuck for almost two days
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
제품
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)


