Mesh plot in GUI works, but in separate figure won't plot

2 ビュー (過去 30 日間)
John Petersen
John Petersen 2012 年 8 月 6 日
I have a GUI with axes defined with a Tag 'axes1' When I plot
mesh(handles.axes1,x,y,z)
where x and y are column vectors, and z a 2d array, everything plots just fine on the GUI. But if I plot a figure separate from the GUI, it only plots the axis and the background is gray instead of white.
I've tried two approaches
figure; H=gca;
mesh(H,x,y,z);
f = figure();
H = axes('Parent',f);
mesh(H,x,y,z);
but both approaches yield the same result. A figure with 3D axis and gray background. I can clear axes1 and replot to axes1 with no problem. I don't have the same problem with the mesh example in the help. That is,
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
mesh(H,X,Y,Z)
mesh(handles.axes1,X,Y,Z)
plots fine in both axes. X and Y are 2d vectors instead of 1d that I use, but I don't know if that has something to do with it. What am I not doing correctly to make the 3d plot in a separate figure?

回答 (2 件)

Seyhan Emre Gorucu
Seyhan Emre Gorucu 2012 年 8 月 6 日
編集済み: Seyhan Emre Gorucu 2012 年 8 月 6 日
a=figure;
axes1 = axes('Color',[1 1 1]);
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
mesh(Z);
  4 件のコメント
Seyhan Emre Gorucu
Seyhan Emre Gorucu 2012 年 8 月 6 日
編集済み: Seyhan Emre Gorucu 2012 年 8 月 6 日
It means that you probably need to create another axes which would be:
figure
a=axes
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
mesh(Z);
Seyhan Emre Gorucu
Seyhan Emre Gorucu 2012 年 8 月 6 日
Please note that figure and axes are not the same things. Here you create new figure but you don't create new axes.

サインインしてコメントする。


Seyhan Emre Gorucu
Seyhan Emre Gorucu 2012 年 8 月 6 日
編集済み: Seyhan Emre Gorucu 2012 年 8 月 6 日
Hm. I have a GUI open and when I run my code I get a nice plot at another figure. I can't see why it doesn't work for you. I hope somebody resolves the problem.

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by