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 207007 articles. 0 followers. lunamoonmoon (258) is leader. Post Follow

5 Replies
238 Views

Similar Articles

[PageSpeed] 18
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 (7455)
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 (7455)
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:

Re: bode plot program?
On Wed, 6 Sep 2006 20:41:58 +0200, Heiko Arnemann wrote: > http://www.hpcalc.org/hp49/math/misc/boderv8x1.zip > is working on HP 49G with ROM 2.09 > > it requires the "get it": > http://www.hpcalc.org/hp49/math/symbolic/neopv8x1.zip Installation went fine, but I have a problem. There's no picture. when I enter the data and say I want a BodePlot, when I click Draw, the grid appears but there's no function drawn, just the crosshair. help! On Thu, 7 Sep 2006 22:27:37 +0200, sNNooPY wrote: > On Wed, 6 Sep 2006 20:41:58 +0200, Heiko Arnemann wrote: > >...

help plot log[f[t]] vs a parameter using an ODE
I've solved the following equation for y[t]. eqn = y'[t] == a (y[t]/((y[t])^2 + b )) - c y[t] + d keqn = eqn /. {a -> 10 , d -> 0.1 , c -> 1 , b -> 10 } ksol = NDSolve[{keqn, y[0] == 0}, y, {t, 0, 200}] Plot[y[t] /. ksol, {t, 0, 200}, PlotRange -> All]; Now I would like to plot the log of y[t] while varying a over a range of values ( 0-40) How will I accomplish this? It seems like I would have to solve the DE while varying a a little at a time then take the log of it? At first I thought the following will do the trick, but it didn't. I was tr...

Plotting
Hi, I am trying to plot a series of randomly generated line segments. However for some weird reason the following code is not plotting all of them. For example, if I were to set the num variable to 3, it only shows either 1 or 2 lines. If i set it to 6, it only displays 4 lines... I'm lost!! If you need more parts of my code please let me know. Thanks. for i = 1:num if (i == 1) axis([0 film_length 0 film_length]); hold all; end X{i} = originX(i,1):0.1:endX(i,1); Y{i} = slope(i,1) * X{i} + intercept(i,1); p = plot(X{i},Y{i}); if (type...

How to plot shaded relief image
Dear guys: How to use IDL to plot shaded relief image, just like http://denali.gsfc.nasa.gov/gridview/index.html? Thanks very much! Dave Dave writes: > How to use IDL to plot shaded relief image, just like > http://denali.gsfc.nasa.gov/gridview/index.html? Thanks very much! 1. Download the GRIDVIEW application. 2. Download a GRID. Otherwise, you could take your topographic data and drape another dataset over the top of it as a texture map: http://www.dfanning.com/ographics_tips/imgtex.html Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coy...

Give plot in figure a position/dimension.
Hi, in an existing figure i want to plot. I experiment with subplot, but I cannot give a position for the plot. I know the Order subplot(1,1,1); subplot('Position',[3 3 100 20]); plot(f,MX); but it does not work :( he always takes the dimensions from 1,1,1 oder 2,1,2 or so... but not the position?? Please help me... In Advance Anis > in an existing figure i want to plot. > I experiment with subplot, but I cannot give > a position for the plot. > I know the Order > > subplot(1,1,1); > subplot('Position',[3 3 100 20]); > plot(f,MX); > > but i...

to get 3d plot
have a code for MVDR algorithm ,how to convert it into 3d plot. On Mar 18, 5:16=A0am, "ramya ramya" <ramya_...@yahoo.co.in> tersely wrote: > have a code for MVDR algorithm ,how to convert it into 3d plot. (As if I know what every acronym in the world is)...perhaps you might try scatter3() or surf(), or even better, a more complete post describing what you're trying to plot (what is the form of the data and what do you want it to look like). ...

Density plot from multiple plots
Hi, I use plot(x_axis, OriginalData); hold all; for trial=1:1000 f = getData(...); plot(x_acis, f); end The different f-functions are all concentrated around "OriginalData" (more or less randomly with some variance). I want to plot now the "envelope" as well as a "density" plot, i.e. where most of the instances lie. I played around with creating a matrix and manually using a counter but that does not only take hours but it's also unreliable (needs to precicly know the dimensions) and the interpolation between the points is ...

Probability scale plot
Hi, there, Is it possible to set the y axis of plot figure to probability scale? I need to plot some grain-size data, of which the y axis (accumulated percentage) should be in probability scale and the x axis (size) should be in linear scale. Thanks in advance. I don't understand exactly what you want. The built-in axis scales in MATLAB are linear and log. There's a "normplot" function in the Statistics Toolbox that creates a plot on which the y tick marks have labels between 0 and 1 and are spaced according to the quantiles of a normal distribution. If you just w...

Bode plot from step response data
Hello all, I have step response data of my system and I want to get a bode diagram from this data. Is there any way to do this?? thanks, scorca "Scorca " <benny_scorca@yahoo.com> wrote in message <h6iu5i$gh2$1@fred.mathworks.com>... > Hello all, > > I have step response data of my system and I want to get a bode diagram from this data. Is there any way to do this?? > > thanks, > > scorca > I did some research and found that fft could possibly do it but I'm not sure. Anyone knows more about fft?? Use System Identification Toolbox. ...

Re: How to make large graphics object fit within a plot?
On 12/3/09 at 6:13 AM, nma@12000.org (Nasser M. Abbasi) wrote: >I am trying to add a disk at some location on top of an existing >plot. So I use Epilog to add the disk. >But it seems if the disk is larger than the plot image size, it gets >chopped off. I wanted the whole disk to show. >I tried increasing ImagePadding for the plot, and also ImageMargins, >but this did not help. >Here is what I tried >Plot[Sin[x], {x, 0, 10}, AspectRatio -> Automatic, >Epilog -> {Disk[{5, 0}, 2]}] >Show[Plot[Sin[x], {x, 0, 10}, AspectRatio -> Automat...

Query set within a specific amount of days
I am a new user and am trying to create a query to show the renewals that will come up within the next two months. I already have: Now()And I am not sure how to input "two months" Please Help Michelle, You could use something like this as the criteria for under your renewal date field. Cut and paste this in the criteria. (Air Code) Between Date() And DateAdd("m", 2, Date()) This will return renewals between todays date and 2 months from today. -- Reggie ---------- "Michelle" <mstringer@peregrin.ca> wrote in message news:265f62ff.0406101421.5cdd4df5@...

VB program to plot to pdf
I am trying to write a program in Visual Basic that will create a pdf of all dwg files in a folder. The API call "PlotToFile" works just fine if I create a dwf file, but does not work with pdf. It creates the pdf file, but it will not open in Adobe. I have tried two different shareware pdf writer software packages, cutePDF and deskPDF, and neither one work. Is what I am doing possible or am I doing something wrong. As a side note, I can manually create the pdf files with same pdf plotter I configured with the plotter manager. Any help would be greatly appreciated. Thanks...

Line plotting blues.....!!!
Greetings, I need to drawn a line that appears in different colors(the color is indicated by a number). Can we change the color of the line at a point??? Or does that change the color of the complete line?? For this reason i have create different line objects of different colors and plot them when that respective color is given as input. But the problem is... i plot three points with line a i plot three points with line b and again if i plot line a with the last value of line b, its connecting to the last value of line a. how do i overcome this problem?? Thanks in advance... SUD Ive com...

plot with different ranges
I want a fit function to be plotted only in a special range: plot [x=0:400] 'Data.txt' using 1:2, [x=100:400] f(x) however seems not to work. Is this somehow possible ? If not, then this could mean that I would have to use another tool, simply because I can not print a fitfuntion in the whole graph because that would mean that the fit is relevant in the whole plot which is not true. (gnuplot 4.1) Matthias -- www.matthiaspospiech.de Matthias Pospiech <matthiasPUNKTpospiech@gmx.de> writes: > I want a fit function to be plotted only in a special range: ...

surf plot boundaries
Hello, I'm using surf() to plot a 20x20 matrix. Surf() correctly shows a 20x20 grid in the resulting plot, but the lower X and Y bounds are 0. Since matlab arrays start with element index number '1' and not '0', the lower row/column are empty in the plot. Also, the last row/column of data is lost, even if I change in axis bounds (from 0:20 to 1:21). I know I can fix this error by padding the matrix with one row and column of zeros, but I assume I'm missing something here that would make it easier. Does anyone know how to address this issue? Am I making a mistak...

Re: Selecting the right error for split-plot repeated measures
I'll pare this down to the statement: "I have tried proc mixed instead but I don't like the output it provides." Because PROC MIXED is ideal for a split plot analysis with covariates (and GLM most definitely is not, unless you make multiple runs), I wonder if maybe we couldn't generate the output you are looking for somehow. Could you say what you don't like? As far as what you have, it appears to be "correct" in the sense that the proper error terms are being used to test effects. I would expect separate p values for your dependent variables, as you have ...

Process X values in Parametric plot
Hi all, its been a while... I am writing some ocean scripts to work out sensitivity of various specifications to design variables. What I would like to do is to process the X values so I can show them in % terms rather than the absolute value set for the design variable being changed. For example, say I am varying a width of a device, and plotting ac- gain. The normal result from the parametric simulation would be a graph of the width on the x axis against the ac-gain on the y axis. However, I want to show the % change from the mean value of the width on the x axis and the % change from the ...

Plotting #16
hallo i amworking with some plottings of heat transfer.(temperature and time).i have put break condition for temperature line at certin time limit.now i want to start from that breakpoint and want to put more data from that break point but with time increasing but temperature remain same as was at break point. can u suggest mesomething? thanks alot Adeel Adeel wrote: > hallo > i amworking with some plottings of heat transfer.(temperature and > time).i have put break condition for temperature line at certin time > limit.now i want to start from that breakpoint and want to put more ...

centering the image plot EXACTLY?
Whenever I plot something using PLOT, the figure is never exactly centered due to the numbers on the left hand side and on the bottom taking up a bit of space and thus displacing the image by that amount. How can I get the image to be EXACTLY centered? I don't need the number info or tick marks or border at all and just want an exactly centered image on the page, but even when I set AXIS to OFF the image is still not centered and acts as if the numbers were still there. ...

Removing the rear surfaces of the plot box in 3D plots
Hello, I have a 3d plot, and I'd like to remove (or make transparent) the rear surfaces that bound the plot space (the surfaces corresponding to x=xlim and y=yllim). Essentially, all that should be visible is the z=0 plane, viewed at an angle. I've looked through the documentation and I must've missed how this can be done. Could someone help me with this please? Many thanks, PLH. For now, I've used axis off, although it would be nice to know if it's possible to still retain the x and y axes. "PLH" wrote in message <ih6uss$4up$1@fred.mathworks....

Contour Plots with Vectors
I've done quite a bit of reading over this topic and still can't quite get my code to work. I have three 1 dimensional vectors. The x and y values correspond to cordinates and the z values will be a magnitude reading taken at the x and y cordinates. For example x=[1 4 2 3] y=[5 4 2 6] z=[1.1 1.9 1.6 1.2] I need to make a contour plot of this data. I know I need z to be at least a 2x2 matrix and so the data must be interpolated at the points I don't know. My question is if I know the values below how do I use interp2 to find the '+' values so I can use that re...

plot problem #2 406102
I want to plot 3 side of cuboid. cuboid dimension = 5*4*2 When I plot three subplot of different dimension 5*4 4*2 5*2 its should looks more or less similar dimension. SO how to get actual size of image? I use command like imagesc(test set(gca,'ytick',[]) set(gca,'xtick',[]) xlabel ('Z') ylabel ('X') axis image colorbar; drawnow please guide me how to control image in subplot. "mat001 " <priya.biomath@yahoo.co.in> wrote in message <i6vjjk$bha$1@fred.mathworks.com>... > I ...

Plotting a x,y,z function
I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what is the keyword/whatever for radius? Or do I have to define r in terms of x,y,z somehow?! Help with syntax will be great! Thanks! The radius is Norm[{x, y, z}] Sqrt[Abs[x]^2 + Abs[y]^2 + Abs[z]^2] Since you are dealing only with real values Simplify[%, Element[{x, y, z}, Reals]] Sqrt[x^2 + y^2 + z^2] f[x_, y_,...

Circular buffer. I need to plot continuously in an xy graph...
Circular buffer. I need to plot continuously in an xy graph two signals and i do not how to create a circular buffer to hold the data.Mads if you or somebody else can help me with this. ThanksHere is attached the program I need to plot continuously in an xy graph two signals and i do not how to create a circular buffer to hold the data.Mads if you or somebody else can help me with this. There is a shipping example called XY Chart that makes use of a subVI called XY Chart buffer. It works like the built-in buffer of a regular chart in that you can specify the length of the buffer. For short a...

Real-Time Plot #2
Hi, I am having a problem plotting a graph in real time. Here are the details: I have a function being called on a timer. This function continues the plot of a graph each time it is called. I am trying the HOLD('ON') command, but this overlaps my graph and does not continue from where the graph was previously plotted from. In short, my issue is continuing the plot from its previous position, and shifting my current plot by the length of the timer calls. Thus, it represents some sort of real-time monitor. The issues I need help with involve: 1) sending into the func...