Plot 2 Figures on a GUI (guide)

1 Ansicht (letzte 30 Tage)
Nicholas Wills
Nicholas Wills am 26 Nov. 2017
Kommentiert: Birdman am 26 Nov. 2017
I have a GUI created in guide which has two axis on the GUI itself. I have a button which runs a separate function (which cannot be included in the GUI main script due to complexity) which generates two graphs. I want these two graphs to plot on the GUI. When I run the usual plotting method, one graph is plotted on the GUI, the other opens in a separate figure. How would I go about changing this?
As an example, I have created the below code. plot(x,y) plots on one axis on the GUI, plot(y,x) opens in a new figure.
function example
x=[1:10];
y=x.^2;
plot(x,y)
figure;
plot(y,x);
end

Akzeptierte Antwort

Birdman
Birdman am 26 Nov. 2017
x=[1:10];
y=x.^2;
subplot(2,1,1)
plot(x,y)
subplot(2,1,2)
plot(y,x);
  4 Kommentare
Nicholas Wills
Nicholas Wills am 26 Nov. 2017
I meant the axis resizes not the whole GUI, but thank you anyway
Birdman
Birdman am 26 Nov. 2017
For that, you need to set limits for x axes. With that, auto resizing will not happen.
set(gca, 'XLim', [0 10]);%as an example

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 26 Nov. 2017

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by