Plot to a specific figure

I activate and get the handle to a specific figure by

h=figure(2);

and plot to it using

for tt = 0:1:T
    plot(U(tt+1,:),'o'); axis(xs);
    title(sprintf([txt ', t=%d (of %d)'], tt, T), ...
        'fontweight','b','FontSize',12);
    xlabel(strXlbl,'fontweight','b');
    ylabel(strYlbl,'fontweight','b');
    drawnow;
end

But if I click on figure 1, Matlab starts plotting to that figure and I lose what's there. How do I force plotting to a figure even if user clicks on another? It's not in documentation for plot or figure command.
0
7/10/2013 6:16:07 PM
comp.soft-sys.matlab 209022 articles. 11 followers. lunamoonmoon (258) is leader. Post Follow

5 Replies
355 Views

Similar Articles

[PageSpeed] 41

On 7/10/2013 1:16 PM, Jeff wrote:
> I activate and get the handle to a specific figure by
>
> h=figure(2);
>
> and plot to it using
>
> for tt = 0:1:T
>   plot(U(tt+1,:),'o'); axis(xs);
>   title(sprintf([txt ', t=%d (of %d)'], tt, T), ...
>                      'fontweight','b','FontSize',12);
>   xlabel(strXlbl,'fontweight','b');
>   ylabel(strYlbl,'fontweight','b');
>   drawnow;
> end
>
> But if I click on figure 1, Matlab starts plotting to that figure and I
> lose what's there. How do I force plotting to a figure even if user
> clicks on another? It's not in documentation for plot or figure command.

Au contraire... :)

 >> help figure
  figure Create figure window.
     figure, by itself, creates a new figure window, and returns
     its handle.

     figure(H) makes H the current figure, forces it to become visible,
     and raises it above all other figures on the screen.  If Figure H
     does not exist, and H is an integer, a new figure is created with
     handle H.
     ...

Once you've got the handle, use it as the second form to make it the 
current figure.  To be effective if you have more than one that you want 
to use at a time then you need the handle variable to be a vector of 
handles and you must select the correct one for the desired target.

You can retrieve the current figure w/ gcf and compare to the desired; 
if not the same execute the figure(h(index_desired)) before the plotting 
commences in the function.  Or if the figure is known to be a specific 
one for the function, just hard code it in--if it exists it will make it 
current; if it doesn't it'll create a new one and make _it_ current...


--
0
none1568 (7453)
7/10/2013 6:32:14 PM

"Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message 
news:krk8d7$79h$1@newscl01ah.mathworks.com...
> I activate and get the handle to a specific figure by
>
> h=figure(2);
>
> and plot to it using
>
> for tt = 0:1:T
>    plot(U(tt+1,:),'o'); axis(xs);
>    title(sprintf([txt ', t=%d (of %d)'], tt, T), ...
>        'fontweight','b','FontSize',12);
>    xlabel(strXlbl,'fontweight','b');
>    ylabel(strYlbl,'fontweight','b');
>    drawnow;
> end
>
> But if I click on figure 1, Matlab starts plotting to that figure and I 
> lose what's there. How do I force plotting to a figure even if user clicks 
> on another? It's not in documentation for plot or figure command.

If you have a handle to the _axes_ on figure 2, use that.

% Create two axes and store their handles
ax1 = subplot(2, 2, 1);
ax2 = subplot(2, 2, 4);

% make the lower-right corner axes "active"
axes(ax2)

% plot into upper-left axes
plot(ax1, 1:10, 1:10)

% lower-right axes is still "active"
isLowerRightActive = isequal(gca, ax2)

% As we can see by plotting into it
plot(0:0.1:2*pi, sin(0:0.1:2*pi))

Specifying the figure is not sufficient, since there may be (and in my 
example there are) multiple axes on the figure. PLOT, TITLE, XLABEL, and 
YLABEL each allow you to specify the axes handle as the first input to plot 
into or manipulate that specific axes.

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

0
slord (13691)
7/10/2013 8:27:55 PM
dpb <none@non.net> wrote in message <krk9bb$4hc$1@speranza.aioe.org>...
> On 7/10/2013 1:16 PM, Jeff wrote:
> > I activate and get the handle to a specific figure by
> >
> > h=figure(2);
> >
> > and plot to it using
> >
> > for tt = 0:1:T
> >   plot(U(tt+1,:),'o'); axis(xs);
> >   title(sprintf([txt ', t=%d (of %d)'], tt, T), ...
> >                      'fontweight','b','FontSize',12);
> >   xlabel(strXlbl,'fontweight','b');
> >   ylabel(strYlbl,'fontweight','b');
> >   drawnow;
> > end
> >
> > But if I click on figure 1, Matlab starts plotting to that figure and I
> > lose what's there. How do I force plotting to a figure even if user
> > clicks on another? It's not in documentation for plot or figure command.
> 
> Au contraire... :)
> 
>  >> help figure
>   figure Create figure window.
>      figure, by itself, creates a new figure window, and returns
>      its handle.
> 
>      figure(H) makes H the current figure, forces it to become visible,
>      and raises it above all other figures on the screen.  If Figure H
>      does not exist, and H is an integer, a new figure is created with
>      handle H.
>      ...
> 
> Once you've got the handle, use it as the second form to make it the 
> current figure.  To be effective if you have more than one that you want 
> to use at a time then you need the handle variable to be a vector of 
> handles and you must select the correct one for the desired target.
> 
> You can retrieve the current figure w/ gcf and compare to the desired; 
> if not the same execute the figure(h(index_desired)) before the plotting 
> commences in the function.  Or if the figure is known to be a specific 
> one for the function, just hard code it in--if it exists it will make it 
> current; if it doesn't it'll create a new one and make _it_ current...
> 
> 
> --

But that keeps bringing figure 2 back to the top. I guess I wanted a way to plot to figure 2 even while it stays in the background (my question was not clear).
0
7/10/2013 8:45:13 PM
On 7/10/2013 3:45 PM, Jeff wrote:
....

> But that keeps bringing figure 2 back to the top. I guess I wanted a way
> to plot to figure 2 even while it stays in the background (my question
> was not clear).

Ah...the transparent glistening orb was silent on that point! :)  I 
presumed it would be that you would want the one being updated to be 
current and on top.

As Steven says, you then need more granularity -- keep the axes handles 
(and you'll have to keep them straight as to which are on which figure) 
and use them to plot directly to the desired one.

--
0
none1568 (7453)
7/10/2013 9:14:31 PM
dpb <none@non.net> wrote in message <krkirk$vav$1@speranza.aioe.org>...
> On 7/10/2013 3:45 PM, Jeff wrote:
> ...
> 
> > But that keeps bringing figure 2 back to the top. I guess I wanted a way
> > to plot to figure 2 even while it stays in the background (my question
> > was not clear).
> 
> Ah...the transparent glistening orb was silent on that point! :)  I 
> presumed it would be that you would want the one being updated to be 
> current and on top.
> 
> As Steven says, you then need more granularity -- keep the axes handles 
> (and you'll have to keep them straight as to which are on which figure) 
> and use them to plot directly to the desired one.
> 
> --
Thanks. I hadn't seen Steven's reply when I replied.
0
7/11/2013 1:06:07 AM
Reply:

Similar Artilces:

dock a matlab figure in another matlab figure
I have an easy questions for you expert of matlab. I need to dock a matlab figure in another figure. What is the procedure ??? Thanks for your precious help, Chris Chris wrote: > I need to dock a matlab figure in another figure. Hi, AFAIK, you can't. J�r�me J�r�me wrote: > Chris wrote: > >> I need to dock a matlab figure in another figure. > > Hi, > > AFAIK, you can't. > > J�r�me there's something "similar" since matlab 7 (afaik). however, i don't know how to control this from a program: - open two figures - on each, cli...

Plot on Specific figure
Hello, I have data generating in loop, while within the loop there are as many as 4 figures comes to display for user selection. Every time when the loop reach to end all the windows close except two. The question is I want to subplot the generating data on the one of the two already open figure specific figure, how can I do it. I have tried following, but not sucessful. Please suggest. if p==1, figure('name','sb'),subplot(2,5,p);plot(x(:,1),x(:,2),'bo');title(['CP # ',num2str(p)]); else findobj('name','sb'),subplot(2,5,p);plot(x(:,1),x(:...

Matlab is not plotting figures anymore..
Hallo! I have installed Matlab7 on my labtop and tried to run a programme which was o.k. under 6.5. Now the entire Matlab surface does not respond when I execute the plot command. Simple try A=[1 2 3] B=[4 5 6] plot(A,B) results in a pop-up of a picture frame and a break-down of Matlab. Matlab has to be quit in the Task manager without responding anymore. What is the problem! Lukas ...

How to plot in MATLAB this simple figure
Hi all I was lookint at this figure which was done in matlab http://mirlab.org/jang/books/audioSignalProcessing/example/dp/output/dtw1Plot01.png I'm trying to understand how to position the plot in the left and the plot just under the square matrix in that particular position. I'm not sure it is something done with the subplot command. Any idea? I've seen this kind of plot several times (with two time series and their distance matrix in that configuration) but not been able to replicate so far thanks -- questo articolo e` stato inviato via web dal serv...

Matlab plot figure in Labview
Is there a way to directly display a Matlab plot figure within the front panel of a VI? I know one option is to save the plot as a .jpg or a 2D image array. Is there a way I can have the created plot figure be displayed in an image box within the vi front panel instead of as a separate matlab figure. Hoping to avoid re-engineering the figures using the Labview plot options. Art, If you are reading data returned from matlab, why not use some of the LabVIEW plots to display that data on its front panel? Do you necesarly want to see matlab's plot? The ways to display actual matlab plot on...

Plotting Matlab figures on the Server
Hi, I have written a Matlab code which takes the data from a huge text file and plots all the parameters with respect to time. I have created an exe file and executed it on the standalone PC. I am able to see all the plots. The runtime compiler is very well installed before executing the file. Same .exe file when I am executing on the server, the plots are blank without any axes. The complete screen is blank with dark color. I am not understanding where the problem is. I am trying to store all the plots in JPEG format. Kindly help me out in printing the plots on Server side. messi2009...

Matlab figure and plotting is slow
I'm quite sure this is not an issue with my code, as my code runs much more quickly on a less powerful machine. Basically, matlab is quite slow in generating and plotting figures. The program generates probably hundreds of figures one after another in order to save them to the disk. On a slower, 2.8ghz P4 machine with 1.5 gb of RAM it generates about one figure a second. In contrast, on my 2.8ghz core 2 duo with 4gb(practically 3.3gb since i'm running vista 32) of RAM it generates about one figure every 4-5 seconds. I also have parallel computing enabled for MATLAB on the more powerful computer. I've checked process explorer while matlab is running, and there isn't much memory consumption other than matlab, which takes about 350mb and 50% cpu. Any possible reasons as to why? Thanks in advance! "asdf asdf" <don7.sp4m.me@gmail.com> wrote in message <h62fa2$72m$1@fred.mathworks.com>... > I'm quite sure this is not an issue with my code, as my code runs much more quickly on a less powerful machine. > > Basically, matlab is quite slow in generating and plotting figures. The program generates probably hundreds of figures one after another in order to save them to the disk. On a slower, 2.8ghz P4 machine with 1.5 gb of RAM it generates about one figure a second. In contrast, on my 2.8ghz core 2 duo with 4gb(practically 3.3gb since i'm running vista 32) of RAM it generates about one figure every 4-5 seconds. I also have pa...

MatLab crashes when plotting figures
Hi I have a very strange problem with matlab and I have no idea how to solve it. Maybe somebody here had the same problem and could give me a hint. I am using Suse Linux 10.1, with KDE and i have the matlab Version 7.0.0.19901 (R14). So my problem is that about every second time i am plotting a figure, my whole system crashes and goes back to the login window. I had the problem before, that I can not save any figure, otherwise matlab crashes and that i can not use the zoom with the mouse or anything like that. But I had never the problem that my whole system crashes. I mean, it is Linux, I never heard of problems with crashing systems there.. So if anybody has the slightest idea, I would be more than happy! Hi, I think you should contact the support : http://www.mathworks.com/support/bugreports/ J�r�me J�r�me wrote: > > > Hi, > > I think you should contact the support : > > <http://www.mathworks.com/support/bugreports/> > > J�r�me > I did that.. but I thougth I just ask here, maybe somebody had the same problem, then answers normally come faster :) Hi Corinne ! I actually have the same problem. I'm working with Fedora Core 5, running under KDE 3.5.6. I load 2D data, do a surf plot of it and maybe it works or it crashes. Eventually it crashes, just a matter of time and how often I do plots. Sometimes the first plot dies, sometime I can plot 10 graphs and then it crashes my whole X-server. The Matlab versions I've tried are R2...

Creating a plot with line plot and scatter plot in the same figure
Hello, I am looking to plot a line plot of a function (say, x^2) and a scatter plot of various data points on the same figure. Is there a way to do this? Perhaps it involves using the "hold on" command? Thanks so much for your time! Andrew "Andrew " <rearwindow1954@yahoo.com> wrote in message <g6d0vs$kfq$1@fred.mathworks.com>... > > Perhaps it involves using the "hold on" command? > Likely yes. Bruno ...

marking a specific point in matlab plot.
i have plotted a plot using plot function. I wanted to mark a point (precisely,) lets say with y-coord: 0.160898403. How would i mark this point? help plz? quasistar <mayur.ec.iitkgp@gmail.com> wrote in message <1872666693.67262.1278227925911.JavaMail.root@gallium.mathforum.org>... > i have plotted a plot using plot function. I wanted to mark a point (precisely,) lets say with y-coord: 0.160898403. How would i mark this point? help plz? a hint: help line; help plot; us ...

Insert a figure into a Matlab figure
I created two MATLAB figures. I want one of them is inserted into the other. Can anybody please reply how this can be done. Thanks. Frank. It depends on what you actually want to do. But normally you would not create two figures if you only want to end up with one figure. Instead you would continue to add plots to the figure window. See the help on these subjects: hold subplot axis plotyy aslak <http://www.glaciology.net/ag> Hi, try this : load clown colormap(map) axes('Position',[.1 .1 .8 .8]); imagesc(X) axes('Position',[.1 .1 .4 .4]); imagesc(X) J�r�me Ooopp...

plot maple plot in matlab
Hi Does anyone know how to export surface plot from maple with multible surfaces to a file format that can be easily plotted using matlab? Thanks in advance Regards Brian Brian Bak wrote: > Does anyone know how to export surface plot from maple with multible > surfaces to a file format that can be easily plotted using matlab? Which maple command are you using to generate the surface plot, and what options are you using for it? If I recall correctly, Maple 12 added options to code the coordinates as hardware floats, and added options to represent the coordinates i...

Matlab plots outside Matlab
I'm making an end-user application where I would like to use Matlab functionality both for calculation and plotting. Matlabs GUI builder guide does not satisfy my needs (no support for f.ex. internal frames and other nescessities), so I'm planning to compile my Matlab code and use other API (Java, QT or something) for GUI. My problem is then, that I loose access to the neat plotting commands availible under matlab GUI... Is there a way of integrating Matlabs plot functionality into another GUI system? - has it been done? - I appreciate any response! - P�l Berge ...

plotting in matlab
hello, i have a probably very simple question, all i try to do is plotting multiple graphs that also have the same scale in one figure - but giving them different colour and caracter. i aditionally want to devide the graph at one point (lets say y=10) with a red line... i have the graphs as five (1,48) matix. and i would like to smothen the graph using something like spline... i have tried figuring this with matlab help - but it is out of my scope does anyone know an example that i can look at so i can figure how to code this??? this is my first contact with matlab and i am not too comforta...

plot a figure in a specified figures..!!
Hello, everyone... there are four axes objects, but I want to use a specfied axes object, how can I do..?? thanks.. curious wrote: > > > Hello, everyone... > > there are four axes objects, but I want to use a specfied axes > object, how can I do..?? > > thanks.. Hi, You can use the axes function to set the current axis. You didn't tell us how you are choosing the specified axes you want to use, so I can't really help much more... An example: figure h(1)=subplot(2,1,1);plot(1:10) h(2)=subplot(2,1,2);plot(2:6) axes(h(1)) title('This ...

How to save a specific plot as image and then use that image to plot into 3d plot.
I would like to know if there is any way to plot image (jpeg,tiff,bmp) on axis plot. I am currently doing a 3D volume (6 surfaces) plotting function which involves very large data set (more than 100MB worth of file size). The data will create 6 surfaces; top,bottom,left,right,front,back. While I can load the volume cube (using surf), rotating or zooming in/out really slows down/sometimes hangs the graph. I understand it happens because of the amount of data it needs to process over every rotation. My question is, are there any way to save each of the surfaces as images. This is so I can repl...

Get Number of plots automatically on saved matlab figure
Lets think we have a figure as; figure(1),plot(1:10);hold on;plot(2:2:45) and save this figure. When i open it as *.*fig format, i want to get information from figure(1) how many plots on it. There is 2 plots on figure1, but i would like to get this automatically to give another function. "mustafa senkaya" <mustafasenkaya@gmail.com> wrote in message news:l3bfre$4m4$1@newscl01ah.mathworks.com... > Lets think we have a figure as; > > figure(1),plot(1:10);hold on;plot(2:2:45) > > and save this figure. When i open it as *.*fig format, i want to get > information from figure(1) how many plots on it. There is 2 plots on > figure1, but i would like to get this automatically to give another > function. Take a look at the FINDOBJ and FINDALL functions. -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com ...

How to save a plotted figure into .jpg(or .bmp, or the others ) file by Matlab instructions?
How to save a plotted figure into .jpg(or .bmp, or the others ) file by Matlab instructions? e.g.I want to save the figure by Matlab instructions produced by the following codes X=[-pi:pi/100:pi]; Y=sin(X); plot (X,Y); How should I do? Thanks ...

[Linux/KDE, display, plot] How to force matlab to use a specific desktop
(sorry for mailing twice, I had used a wrong thread on my first post) Hi, I run Linux with KDE and have 4 desktops I use for different activities (e.g. email/web, typesetting, matlab computations, etc...) Is there a way to force matlab in using only a specific desktop when opening new windows? It is annoying to have the plots popping up in the middle of some LaTeX command battle and distract my attention. Furthermore, I have a similar issue when I run multiple simulations from different computers which are all to be displayed on my screen. It would be nice to have the results from the sim...

How to save a plotted figure into .jpg(or .bmp, or the others ) file by Matlab instructions? #2
How to save a plotted figure into .jpg(or .bmp, or the others ) file by Matlab instructions? e.g.I want to save the figure by Matlab instructions produced by the following codes X=[-pi:pi/100:pi]; Y=sin(X); plot (X,Y); How should I do? Thanks je2ccc <e98@msn.com> writes: >How to save a plotted figure into .jpg(or .bmp, or the others ) file >by Matlab instructions? help print help getframe % possibly want getframe(gca) or getframe(gcf) help frame2im help imwrite (don't use jpg except for photo like pictures. For your example, tiff or png) John Tim Love wrote: > ...

Difference between plot in figure and plot in GUI?
Hi world!! I have programmed a code that plots the earth and then plots the orbit of a satellite by using a text of x,y,z coordinates. The code of the earth is programmed by the command "sphere" and then with the "surface" i give a "texturemap" with the "topo" cdata. When i run it from command window is made a figure where plotted small lines, which is the orbit's curve, and the plot is completed in about 30 seconds. I've made a GUI so that will be plotted, instead of a figure, in the GUI's environment.Now the strange thing is that the code...

how to plot 10 figures in one figure
Hi, I want to draw 10 figures in one figure and would be grateful if any one please guide me through or write a piece of code here. I want to have 10 subplots in one figure. Thanks On May 15, 10:40 am, subzazar <baarish_bar...@hotmail.com> wrote: > Hi, > > I want to draw 10 figures in one figure and would be grateful if any one please guide me through or write a piece of code here. I want to have 10 subplots in one figure. > > Thanks Your expectations are too high. No one in their right mind at CSSM is gonna "write a piece of code" for you. Have you thought ...

Plotting a Colour lined plot in Matlab
Hi What i'm trying to do is plot a 2D graph of position however this position changes with a known time vector, what i would like to do it have the colour of the 2D plot change according to the time thus the position with respect to time would be known. I've looked at a code created a few years ago on this page, shown below function h = c_line(x, y, z, mark) % c_line plots a 2-D "line" with z-data as color % % h = c_line(x, y, z, mark) % % in: x x-data % y y-data % z 3rd dimension for colouring % mark marker or linestyle to use (like linestyl...

SYS$SPECIFIC and SYS$COMMON not enough?
Basically, the idea is that stuff specific to a given node will be in its SYS$SPECIFIC directory and stuff common to all nodes (satellites or not) booting from the same system disk will be in SYS$COMMON. A good idea as far as it goes, but does it go far enough? In particular, there are two additional categories, which I'll give the obvious names SYS$CLUSTER and SYS$WORLD. SYS$CLUSTER would include stuff common to all nodes in a cluster, i.e. would differ from SYS$COMMON if there is more than one system disk in the cluster. The obvious place for this stuff is somewhere which is not ...

Web resources about - Plot to a specific figure - comp.soft-sys.matlab

Specific - Wikipedia, the free encyclopedia
Specific Pathogen Free , of a laboratory animal guaranteed free of particular (i.e., specific and named) pathogens "Specific" generally means ...

Specific activity - Wikipedia, the free encyclopedia
... SI quantity related to the phenomenon of natural and artificial radioactivity. The SI unit of "activity" is becquerel, Bq, while that of "specific ...

Post Planner Launches Time Zone-Specific Facebook Posting Feature
So your company is based in San Francisco, but you’ve got a big fan base in Berlin. Posting to your Facebook page at 3 p.m. from California means ...

New gender non-specific birth certificates for the ACT
Parents can now choose to be known as &quot;mother&quot; or &quot;father&quot; or neither, regardless of their sex

Twitter launches Moments in Australia to collect tweets around specific events
Twitter has begun rolling out its Moments feature in Australia, offering a new, more curated way to discover trending content and keep tabs on ...

Barclays gets more specific on belated adoption of Apple Pay in UK: coming in March
... it would be going ahead but couldn’t say when, before stating that it would be sometime in “early 2016.” The bank has now provided more specific ...

Clinton, Sanders spar over specifics in Iowa
The Democratic candidates squared off on their vision and experience at a town hall in Des Moines

Endpoint specific malware renders signature detection useless
Signature-based security could be virtually useless as 97 percent of malware is unique to a specific endpoint says a new report. This is among ...

Reporter Took Orders from Hillary Clinton’s Staff, Down to Specific Adjective
Reporter Took Orders from Hillary Clinton's Staff, Down to Specific Adjective

This year's Oscars are being presented in a very specific order — here’s why
The Oscars approached the night's awards in a pretty cool way: It handed out the awards in a way that mimics the making of a film. Right before ...

Resources last updated: 3/8/2016 7:10:57 AM