I don't know why hold on wont work- it only produces one graph with one model and not both on one graph
31 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
clear
clear global
%load up a model timestep
load('SIGNUM_6test__Time_180002.mat')
figure
hold on
SIGNUM_drawTIN_g(5e4)
[indices] = SIGNUM_extract_river(240,1);
[along_channel_dist, channel_elev] = SIGNUM_along_channel_dist(indices);
figure
plot(along_channel_dist, channel_elev,'.-')
xlabel('Distance, m')
ylabel('Elevation, m')
load('SIGNUM_6test__Time_40000.mat')
plot(along_channel_dist, channel_elev,'.-')
xlabel('Distance, m')
ylabel('Elevation, m')
0 comentarios
Respuestas (2)
Allen
el 18 de Dic. de 2019
Amber, it looks like you are creating a figure twice and only applying hold on to the first, while plotting to the second. Try placing the hold on command just before you use the plot function. Additionally, to help avoid potentially issues that can arise due to the new figure not having an axes currently in the frame, create a blank axes in the figure just before the hold on command.
...
figure % Create a new figure.
axes % Create a blank axes in the current figure (gcf)
hold on % Turn on the 'add next plot' behaviour for the current axes (gca)
plot( ... ) % Plot as normal
...
Additionally, for improved control in your code when using graphics objects, you can assign object handles to variables and then specify which object you want to perform the function on.
hFig = figure; % Create figure and assign handle to 'hFig' variable
% Additional code can be placed here including the creation of other figures
hAx = axes(hFig); % Create a blank axes in the target figure and assign handle to 'hAx'
hold(hAx,'on'); % Turn on the 'add next plot' behaviour to the target axes
plot(hAx, ...) % Specify the target axes prior to normal input arguments in the plot function
0 comentarios
Guillaume
el 18 de Dic. de 2019
Your code creates a figure and sets the axis to retain plots in this figure with hold on.
Your code then creates a second figure for which by default hold is off. So indeed it will draw one plot and erase it to draw the next one.
After your second figure, issue another hold on. hold is per figure (actually per axis, but your figures have only one axis).
0 comentarios
Ver también
Categorías
Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!