Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
combining plots without using hold

Subject: combining plots without using hold

From: David Epstein

Date: 10 May, 2014 11:23:08

Message: 1 of 5

I have just written a fairly long program which produces many plots. There are several subsets of these plots, and for each subset I want to combine the plots. So, if I started with 10 plots, there would be a possible 2^10 different plots I could create from these. Fortunately, I only want to use 5 or so subsets of my 10 original plots.
Is there a nice way to do this using the handles of the plots? Or using handles of the axes? Or something.

I can't find what I want using Matlab Help, and the usual recourse of using Google doesn't help me either. Everyone wants me to use hold, but there doesn't seem a convenient way of doing so without reproducing some of my original plots over and over again. This approach also has the disadvantage of filling up the space in my computer's memory. I would rather clear the variables.

Another approach would be to save on disk a .fig file for each plot. But I still would need to know how to combine the figures, and, at the moment, I don't know how to do this. I suppose I could save the variables I need for each plot in a .mat file. Surely there is something easier to do using handles.

Subject: combining plots without using hold

From: Bruno Luong

Date: 10 May, 2014 13:07:13

Message: 2 of 5

It's not clear what you want to do, but it seems like COPYOBJ may be your friend.

Bruno

Subject: combining plots without using hold

From: TideMan

Date: 10 May, 2014 20:34:38

Message: 3 of 5

On Saturday, May 10, 2014 11:23:08 PM UTC+12, David Epstein wrote:
> I have just written a fairly long program which produces many plots. There are several subsets of these plots, and for each subset I want to combine the plots. So, if I started with 10 plots, there would be a possible 2^10 different plots I could create from these. Fortunately, I only want to use 5 or so subsets of my 10 original plots.
>
> Is there a nice way to do this using the handles of the plots? Or using handles of the axes? Or something.
>
>
>
> I can't find what I want using Matlab Help, and the usual recourse of using Google doesn't help me either. Everyone wants me to use hold, but there doesn't seem a convenient way of doing so without reproducing some of my original plots over and over again. This approach also has the disadvantage of filling up the space in my computer's memory. I would rather clear the variables.
>
>
>
> Another approach would be to save on disk a .fig file for each plot. But I still would need to know how to combine the figures, and, at the moment, I don't know how to do this. I suppose I could save the variables I need for each plot in a .mat file. Surely there is something easier to do using handles.

What do you mean by "combine the plots"?
Do you mean:
1. I want to overplot on the same axes;
2. I want to paste my plot into a separate panel in the figure;
3. Something else?

Subject: combining plots without using hold

From: Steven Lord

Date: 12 May, 2014 13:21:33

Message: 4 of 5


"David Epstein" <David.Epstein.spam@remove.warwick.ac.uk> wrote in message
news:lkl26s$se9$1@newscl01ah.mathworks.com...
> I have just written a fairly long program which produces many plots. There
> are several subsets of these plots, and for each subset I want to combine
> the plots. So, if I started with 10 plots, there would be a possible 2^10
> different plots I could create from these. Fortunately, I only want to use
> 5 or so subsets of my 10 original plots.

If by "combine" you mean "overlay on the same axes" that sounds like the
plots are going to become very difficult to interpret.

> Is there a nice way to do this using the handles of the plots? Or using
> handles of the axes? Or something.

If I understand what you're trying to do, I second Bruno's recommendation of
COPYOBJ. Or just putting all your figures in separate SUBPLOT axes in one
figure rather than composing them into one axes.

> I can't find what I want using Matlab Help, and the usual recourse of
> using Google doesn't help me either. Everyone wants me to use hold, but
> there doesn't seem a convenient way of doing so without reproducing some
> of my original plots over and over again. This approach also has the
> disadvantage of filling up the space in my computer's memory. I would
> rather clear the variables.

If you want multiple copies of the plots on the screen, there will be some
level of duplication of memory.

> Another approach would be to save on disk a .fig file for each plot. But I
> still would need to know how to combine the figures, and, at the moment, I
> don't know how to do this. I suppose I could save the variables I need for
> each plot in a .mat file. Surely there is something easier to do using
> handles.

What are you planning to do with these overlaid plots? Perhaps the group can
suggest an alternative approach that doesn't require so much duplication of
graphs.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: combining plots without using hold

From: David Epstein

Date: 22 May, 2014 17:28:12

Message: 5 of 5

"Steven Lord" <Steven_Lord@mathworks.com> wrote in message <lkqhst$50p$1@newscl01ah.mathworks.com>...
>
> What are you planning to do with these overlaid plots? Perhaps the group can
> suggest an alternative approach that doesn't require so much duplication of
> graphs.

I've been meaning to reply to all these helpful emails, but I've been very busy. Here's what I ended up by doing:
I made an vector to hold the handles of all plots and lines in which I was interested. I drew all the plots and lines in the same axes, as they all related to exactly the same object, and I was just showing different aspects with each picture. I saved the handles as entries in my vector. Showing everything was of course a total mess. In order to see only a subset of these plots, I turned 'Visible' to 'on' for the objects I wanted to show, and turned 'Visible' to 'off' for all the other objects in the axes. I did this for several different subsets of the handles, obtaining the results I needed to demonstrate. I think this minimized memory used, and also it minimized the amount of code I had to write and its difficulty, ending up with code that seemed to me to be very readable.

I'm sure this is a very standard technique, but I didn't know about it at the time I wrote my original plea for help.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us