Subplot - Plots are not displayed

22 次查看(过去 30 天)
MiauMiau
MiauMiau 2013-1-27
回答: ks905383 2015-8-12
Hi
I use the following easy script do plot some functions in subplots:
x = [1 3 4 5];
y = [2.3 4.1 5.2 -1];
z = [1 1 1 1];
a = [12 13 44 1];
subplot(2,2,1); plot(x)
subplot(2,2,2); plot(y)
subplot(2,2,3); plot(z)
subplot(2,2,4); plot(a)
But when I run the programm, although no error message occurs, also no plots are displayed. Why so? Thanks
  2 个评论
MK_Earth
MK_Earth 2015-7-29
I had the same problem. I just closed and reopen Matlab to trubleshooting

请先登录,再进行评论。

回答(2 个)

the cyclist
the cyclist 2013-1-27
The only thing I can think of is that your current figure window is either off your screen somewhere, or has the 'Visible' property set to 'off', so that it is not displaying.
What do you get for the 'Visible' property if you type
get(gcf)
Also, do you see the plots if you add a figure command in front of your plotting commands?
figure
x = [1 3 4 5];
y = [2.3 4.1 5.2 -1];
z = [1 1 1 1];
a = [12 13 44 1];
subplot(2,2,1); plot(x)
subplot(2,2,2); plot(y)
subplot(2,2,3); plot(z)
subplot(2,2,4); plot(a)
Failing that, I would restart MATLAB, and/or restart your computer. Not sure what to try other than that.
  2 个评论
MiauMiau
MiauMiau 2013-1-27
编辑:MiauMiau 2013-1-27
So, I tried it again and still I see no plots.
Again to repeat what I have done so far: the code
x = [1 3 4 5];
y = [2.3 4.1 5.2 -1];
z = [1 1 1 1];
a = [12 13 44 1];
subplot(2,2,1); plot(x)
subplot(2,2,2); plot(y)
subplot(2,2,3); plot(z)
subplot(2,2,4); plot(a)
has been saved in a .m file and I would just press the "run" button.
When I add "figure" I get an error:
Error using figure Error using figure Error using figure UIJ_AreThereWindowShowsPending - timeout waiting for window to show up
Error in Ex_1 (line 1) figure
And get(gcf) doesn't work either...:-/
the cyclist
the cyclist 2013-1-27
I am not familiar with that error, but it suggests that MATLAB is somehow stuck trying to open a figure window.
You could try
>> close force all hidden
to try to shut all figure windows (and hopefully the pending one), and then try to run your code again.
Does this happen with a brand-new instance of MATLAB, in which you have not run any other commands? If so, that is extraordinarily weird to me, and I have no further suggestions other than to contact MathWorks support.

请先登录,再进行评论。


ks905383
ks905383 2015-8-12
So I had this problem as well, and after messing around for a long time, I found a fix - there seemed to have been an issue with the image renderer it was trying to use. Setting
set(gcf,'Renderer','zbuffer')
Fixed the problem for me (I haven't tried it for different renderers, and I still don't know why this might've happened, without an error message)

Community Treasure Hunt

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

Start Hunting!

Translated by