MATLAB Answers

How can I save a plot to a variable to be printed later? I'm more specifically referring to problems of plots which involve many different legends/ figure objects such as ones created by looping over a hold on command.

3 views (last 30 days)
Hugh Wheaton
Hugh Wheaton on 9 Apr 2020
Commented: Hugh Wheaton on 17 Apr 2020
I've got to do this thing for uni where I loop over a bunch of objects and plot their calculated divergences. They (32 different classes) are all calculated individually, then have a bar plot printed and then are looped over to plot the whole lot sequentially. I need to then plot a separate plot with specific axes and then am further going to do this again.
This computation can take quite a few minutes each time, so it seems so dumb that I have to run it like 5 times every time I need to change one thing, when each of these 5 plots will be plotting the exact same data.


Sign in to comment.

Answers (1)

Rajani Mishra
Rajani Mishra on 13 Apr 2020
To save plot results programmatically use “saveas() function”. Read its documentation below:

  1 Comment

Hugh Wheaton
Hugh Wheaton on 17 Apr 2020
Ay cheers. Turns out I was using the figure function wrong, and the following was probably all I was looking for:
if true
f2=figure(f1) %or f2=figure; and then some type of copy function
ax.xlim etc.
I'll check your answer though, cheers.

Sign in to comment.

Translated by