Multiple axes in GUI

Hi there,

I'm using guide to make a GUI with two axes, but I cannot assign the current figure handle to one of the two axes. It keeps plotting in just one of the axes. Any ideas how to solve this problem?
0
Rasmus
1/7/2010 6:56:22 PM
comp.soft-sys.matlab 206915 articles. 560 followers. lunamoonmoon (258) is leader. Post Follow

20 Replies
2930 Views

Similar Articles

[PageSpeed] 15
You call the axes() function to switch focus between axes, or else
just pass the axes handle in to the plotting routine that you are
using (plot(), bar(), scatter,(), etc.).  Why do you say that you
cannot do this?
0
ImageAnalyst
1/7/2010 7:07:01 PM
"Rasmus" <prof.rasmusolesen@gmail.com> wrote in message <hi5aom$rvp$1@fred.mathworks.com>...
> Hi there,
> 
> I'm using guide to make a GUI with two axes, but I cannot assign the current figure handle to one of the two axes. It keeps plotting in just one of the axes. Any ideas how to solve this problem?

I'm not sure what you mean by "assign the current figure handle to one of the two axes".  The axes have their own handles, and you can pass the axes handle as an argument to the plot command in order to specify where you are plotting:

% The figure and the axes
f=figure;
ax1=axes('parent',f,'position',[0 0 0.9 0.4]);
ax2=axes('parent',f,'position',[0 0.5 0.9 0.4]);

% Two sets of data
x1=1:100;
x2=1:100;
y1=1:100;
y2=sin(x2);

% First argument to plot controls which axes is used
plot(ax1,x1,y1);
plot(ax2,x2,y2);
0
Andy
1/7/2010 7:09:05 PM
By "assign the current figure handle to one of the two axes" I mean the following: I have made two axes in the guide tool and saved it in a .fig file. A callback function will have to plot a graph in either axes1 or axes2.

The code you have written is assigning a figure window outside the GUI figure window, so in some way I'll have to write a handle to the two axes and later get that handle in case of a callback.
0
Rasmus
1/7/2010 8:27:04 PM
Rasmus:
Simply do this:

axes(handles.axesPlot1);
plot(x1,y1);
axes(handles.axesPlot2);
plot(x2,y2);

or do this:
plot(handles.axesPlot1, x1, y1);
plot(handles.axesPlot2, x2, y2);

It will plot in the correct axes.
1
ImageAnalyst
1/7/2010 8:46:08 PM
"Rasmus" <prof.rasmusolesen@gmail.com> wrote in message <hi5g2o$q88$1@fred.mathworks.com>...
> By "assign the current figure handle to one of the two axes" I mean the following: I have made two axes in the guide tool and saved it in a .fig file. A callback function will have to plot a graph in either axes1 or axes2.
> 
> The code you have written is assigning a figure window outside the GUI figure window, so in some way I'll have to write a handle to the two axes and later get that handle in case of a callback.

But when you create a figure in GUIDE, it stores all of the handles for you in the structure names "handles".  So you already have access to the handles of your axes in any callback function in that figure.  I don't understand the problem.
0
Andy
1/7/2010 8:47:02 PM
The problem is the handle list. I assign handles to the axes in GUIDE, but when I use them in the m-file, they are not there - not even a function (Callback, CreateFcn etc.) for the axes.
0
Rasmus
1/7/2010 9:05:20 PM
The problem is the handle list. I write a handle name to the axes in GUIDE, but they are undefined in the m-file, when I try to use them. No code in the m-file even includes the axes.
0
Rasmus
1/7/2010 9:07:04 PM
Sorry for the small comments...

I got the plot(handles.axes1,x1,y1) to work, but no when I want grid in the figure, I can't just write "grid on" as usually. Is there a way to use a command like "figure(handles.axes1)" (this is not the solution) so this is always active?
0
Rasmus
1/7/2010 9:17:23 PM
On Jan 7, 1:07=A0pm, "Rasmus" <prof.rasmusole...@gmail.com> wrote:
> The problem is the handle list. I write a handle name to the axes in GUID=
E, but they are undefined in the m-file, when I try to use them. No code in=
 the m-file even includes the axes.

When you create the axes in GUIDE, they have tags, don't they?
For example, the default tag is "axes1".
To get the handle to this axes, type "handles.axes1"

Why do you expect a function to be created for an axes object?

-Nathan
0
Nathan
1/7/2010 9:20:20 PM
"Rasmus" <prof.rasmusolesen@gmail.com> wrote in message <hi5j13$8vq$1@fred.mathworks.com>...
> Sorry for the small comments...
> 
> I got the plot(handles.axes1,x1,y1) to work, but no when I want grid in the figure, I can't just write "grid on" as usually. Is there a way to use a command like "figure(handles.axes1)" (this is not the solution) so this is always active?

I think it will be clearer to use the function form of commands like grid.  The grid function can take the axes handle as an argument, so if you want a grid on axes1, you can type:

grid(handles.axes1);
0
Andy
1/7/2010 9:23:04 PM
On Jan 7, 4:17=A0pm, "Rasmus" <prof.rasmusole...@gmail.com> wrote:
> Sorry for the small comments...
>
> I got the plot(handles.axes1,x1,y1) to work, but no when I want grid in t=
he figure, I can't just write "grid on" as usually. Is there a way to use a=
 command like "figure(handles.axes1)" (this is not the solution) so this is=
 always active?

-------------------------------------------------
Yes you can - I did it just earlier today.  Maybe you can try the
functional form of it (with the parentheses) like Andy suggested.  The
grid function will operate on whatever the current axes is (the "gca").
0
ImageAnalyst
1/7/2010 9:29:00 PM
Okay, got it to work now with the function form. So there are no easy way of saying that I want to use this axes now, and then do all the plotting and move on with the next axes? I'll just use the handle in every command then.

Thanks for the replies
0
Rasmus
1/7/2010 9:34:05 PM
"Rasmus" <prof.rasmusolesen@gmail.com> wrote in message <hi5k0d$d7n$1@fred.mathworks.com>...
> Okay, got it to work now with the function form. So there are no easy way of saying that I want to use this axes now, and then do all the plotting and move on with the next axes? I'll just use the handle in every command then.
> 
> Thanks for the replies

You can do this.  ImageAnalyst showed you how.  Here is a modified form of my original script:

% The figure and the axes
f=figure;
ax1=axes('parent',f,'position',[0 0 0.9 0.4]);
ax2=axes('parent',f,'position',[0 0.5 0.9 0.4]);

% Two sets of data
x1=1:100;
x2=1:100;
y1=1:100;
y2=sin(x2);

% First argument to plot controls which axes is used
plot(ax1,x1,y1);
plot(ax2,x2,y2);

% Now give control ax1
axes(ax1);
grid on; % only turns on the grid for ax1
hold on; % only turns on hold for ax1
plot(1:100,100*rand(1,100)); % this plots to ax1, since ax1 is the current axes
plot(ax2,1:100,100*rand(1,100)); % this plots to ax2, but overwrites the earlier plot
% the hold on only applied to ax1.




Since using commands like:

grid on;
hold on;

in your code may have unintended consequences (for example, if the current axes unexpectedly changes), I recommend sticking with the functional forms and always specifying the appropriate axes.  It costs only a little time while coding, and it improves both reliability of the code and readability of the code.
0
Andy
1/7/2010 9:51:02 PM
It's all very true
Thanks again
0
Rasmus
1/7/2010 10:03:06 PM
Hi,
I have a similar problem. 
I have a GUI with more axes, I work in an external m file using the handle of the GUI.
What I would like to do is something like :

text(gui_handle.axes1,0,0,'hello world');

but text command doesn't take axes as params, so what i do is the following:

axes(gui_handle.axes1);
text(0,0,'hello world');

but instead of printing in axes1, it open up a new figure1 and plot the text there.

Any ideas?
0
Andrea
4/3/2010 6:57:05 PM
"Andrea " <andrea.alessandre...@gmail.com>

Try this:

axes(gui_handle.axes1);
gui_handle.axes1
gca

See if they both put out exactly the same number to the command
window.  If they don't, you didn't switch axes for some reason.  Maybe
you can try setappdata() and getappdata().

0
ImageAnalyst
4/3/2010 7:21:01 PM
You are right, the numbers are different.

Can you give me an example o how to use setappdata() and getappdata() to solve this problem. I couldn't find it on the mathworks help.
0
Andrea
4/3/2010 9:25:24 PM
On Apr 3, 5:25=A0pm, "Andrea " <andrea.alessandre...@gmail.com> wrote:
> You are right, the numbers are different.
>
> Can you give me an example o how to use setappdata() and getappdata() to =
solve this problem. I couldn't find it on the mathworks help.

-------------------------------------------------------------
You're right that there's no examples in the help for those functions,
but look up "application data" in the R2010a help and there is an
example with explanation there.
0
ImageAnalyst
4/4/2010 1:30:37 AM
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <a90b730f-6bcd-47d9-847a-c0279bb0e183@r1g2000yqb.googlegroups.com>...
> On Apr 3, 5:25 pm, "Andrea " <andrea.alessandre...@gmail.com> wrote:
> > You are right, the numbers are different.
> >
> > Can you give me an example o how to use setappdata() and getappdata() to solve this problem. I couldn't find it on the mathworks help.
> 
> -------------------------------------------------------------
> You're right that there's no examples in the help for those functions,
> but look up "application data" in the R2010a help and there is an
> example with explanation there.


I encountered a similar issue, but slightly complicated by the detail of trying to populate the axes with an initial plot. I noticed that the structure member for the axis was deleted after invoking the CreateFcn for that axis (why?). The simple fix was to add the following lines at the end of the CreateFcn for each axis I was populating on startup of the gui:


function axesX_CreateFcn(hObject, eventdata, handles)
imshow('../myimage.jpg');           % initial image I want to display
handles.axesX=hObject;              % tag for this axis, which I call axesX in this example
guidata(hObject, handles);           % update the handles structure for the gui

Thanks to the above thread for pointing me in the right direction. I have yet to see if my addition is redundant, so please forgive the extra text if it is.

Later,
Stephen
0
Stephen
1/12/2011 5:20:07 AM
"Stephen" wrote in message <igjdm7$4jj$1@fred.mathworks.com>...
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message <a90b730f-6bcd-47d9-847a-c0279bb0e183@r1g2000yqb.googlegroups.com>...
> > On Apr 3, 5:25 pm, "Andrea " <andrea.alessandre...@gmail.com> wrote:
> > > You are right, the numbers are different.
> > >
> > > Can you give me an example o how to use setappdata() and getappdata() to solve this problem. I couldn't find it on the mathworks help.
> > 
> > -------------------------------------------------------------
> > You're right that there's no examples in the help for those functions,
> > but look up "application data" in the R2010a help and there is an
> > example with explanation there.
> 
> 
> I encountered a similar issue, but slightly complicated by the detail of trying to populate the axes with an initial plot. I noticed that the structure member for the axis was deleted after invoking the CreateFcn for that axis (why?). The simple fix was to add the following lines at the end of the CreateFcn for each axis I was populating on startup of the gui:
> 
> 
> function axesX_CreateFcn(hObject, eventdata, handles)
> imshow('../myimage.jpg');           % initial image I want to display
> handles.axesX=hObject;              % tag for this axis, which I call axesX in this example
> guidata(hObject, handles);           % update the handles structure for the gui
> 
> Thanks to the above thread for pointing me in the right direction. I have yet to see if my addition is redundant, so please forgive the extra text if it is.
> 
> Later,
> Stephen

Same issue for me with the handles of axes that curiously vanished after being created. Stephen's idea of forcing the gui structure handles to be refreshed does work. I don't know why, but thanks anyway ...
Sébastien
0
spommier (1)
6/15/2011 12:27:05 PM
Reply:
Similar Artilces:

Multiple data with different colors
Hi, I have three data files which are in same structure, and I know how to plot each of them. Now, I want to combine all of three on a same plot but with different colors. How to do it? I am a newbie of plotting, thank you in advance. On Thu, 18 Dec 2008, Steven Woody wrote: > I have three data files which are in same structure, and I know how to > plot each of them. Now, I want to combine all of three on a same plot > but with different colors. How to do it? Presumably what you've been doing so far is something like plot '1.dat' using ($1):($2) plo...

How to set 'Xdata' for multiple PATCH objects simultaneously???
Hi. How do I set the 'Xdata/Ydata' or 'Vertices' properties for multiple Patch objects with a single SET command? I have the vector of handles (Hvect) to the Patch objects, but I don't want to use a FOR loop to set them one-by-one. How do I set them all in a single command? Thanks very much. -- Dave > Hi. How do I set the 'Xdata/Ydata' or 'Vertices' properties for > multiple Patch objects with a single SET command? I have the > vector > of handles (Hvect) to the Patch objects, but I don't want to use a > FOR loop to set them one-by-one....

Importing multiple files from multiple folders
Dear all, I am trying to import multiple from a folder. However, I have folders inside that folder. So first I want to read the contents of main folder and using the name of the folders inside it , enter into each folder and read the files. This is where I have my real files. But the following code does not seem to work : *************************************************************************** filename indata pipe 'dir J:\1999\199901\Snapshot\1999\Jan /b'; data file_list; length fname $20; infile indata truncover end=last; /* infile statement for file names */ input fname $20.; ...

Re: Excelxp Tagsets: is there a way to create multiple sheets on #2
Satindra, Will this work even if I have intervening ODS OUTPUT statements in my = program? I just tried the sheet name only (without the sheet_interval) = but got sheets every time I specified an ODS OUTPUT file. =20 -Mary ----- Original Message -----=20 From: Satindra Chakravorty=20 To: SAS-L@LISTSERV.UGA.EDU=20 Sent: Thursday, July 10, 2008 11:23 AM Subject: Re: Excelxp Tagsets: is there a way to create multiple sheets = on the same file? I believe the 'sheet_interval' option will do the trick. For example, if you have several PROC steps and you want the output fr...

Embed a GUI design surface in an application
Hello, I'd like to embed a GUI design surface component in my application to allow people to design screens, just regular IDEs allow you to drag&drop widgets on a grid and save the layout. Is there such a component ? Thanks. On Fri, 2 Apr 2004 07:25:57 +0200, Ben_ wrote: > I'd like to embed a GUI... Best asked on.. <http://www.physci.org/codes/javafaq.jsp#cljg> -- Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology ...

Linux Lisp GUI's?
What are the most popular GUI bindings for Linux amongst users on this list? Jeff Rollin wrote: > What are the most popular GUI bindings for Linux amongst users on this list? Ltk of course! SCNR :) Peter -- Ltk, the easy lisp gui http://www.peter-herth.de/ltk/ Jeff Rollin wrote: > What are the most popular GUI bindings for Linux amongst users on this list? The most popular may be Ltk, which is a nice GUI framework for building standard GUI applications, e.g. accounting systems. If you want to program some fast 2D Jump'n Run game, http://www.lispbuilder.org is better. It has...

auto-login multiple accounts
The Accounts system preference allows you to configure one account to login automatically. What I'd like to do is auto-login both my personal account and the admin account, with the admin account running in the background as if I'd fast-switched away from it. One thought I have is to enable the admin account as the auto-login account, and give it as a login item a script that will fast-switch to my personal account. However, this will require me to enter my password in the fast-switch login screen, so it isn't really an auto-login. -- Barry Margolin, barmar@alum.mit.edu ...

Storing multiple Matrix from 'for' loop
I am a new matlab user and facing a problem while using a for loop. I'll appreciate if anybody help me in this regard. My loop if like below: for i=1:100 [P]=getdata(i); end [P] is i depended and 'getdata' will produce a 40x 40 matrix for each value of i. I want catch all 100, 40x 40 matrix and want to use them in later calculation. Is there anyone who can hep me in this case. Regards Shafi Shafi wrote: > I am a new matlab user and facing a problem while using a for loop. I'll > appreciate if anybody help me in this regard. > > My loop i...

multiple tables
Anyone know how to put multiple tables in a single materialized view? bob@coolgroups.com wrote: > Anyone know how to put multiple tables in a single materialized view? create materialized view myview as select mytab1.mycol1,mytab2.mycol2 from mytab1,mytab2 where ... is this the answer to your question? br, stephan ...

Multiple Embedded/ Firmware positions full time
Hello and Good Day, Beyond Innovation, Inc is a staffing company with our corporate office in Livermore, CA. We have seven great full time job opportunities in the Bay Area, CA with our exclusive client; they are an established South Bay Company that specializes in storage and data management solutions. The client is amongst fortune 100 (Multi-Billion) companies. The many positions are focused mainly Firmware, Software and QA Platform Engineer. Pls. do see below for all job descriptions. These jobs offer a competitive salary and superb benefits. Find below the various job descriptions ...

Multiple switches
We have a site that will have upto 80 or so pc's, all cat5e cabling back to 1 rack. We usually use 2950 switches, upto 48 ports, never used anything larger - it seems inefficient to link two of these via a 1GB port. Is there a way to link two or more of these and effectively turn them into 1 switch get full bandwidth) or would we be better off speccing a much larger switch, ive never seen a 96 port in operation but the site is likely to need this many, maybe a few more so trying to work out how best to achieve this. Although most systems will be new and also have gigabit network c...

Limit multiple sessions for one user
Hello, I'm using Oracle 9i. How can I limit the number of opened sessions for one user ? Laurent > I'm using Oracle 9i. How can I limit the number of opened sessions for one > user ? > Create a profile with limited session_per_user. Assign that profile to the user. Stephan I have tried this whis 1 simultaneous session. But I still can open several sessions with my user. Do I need to restart my database ? Laurent "Stephan Bressler" <sbresslerx_no_spam@arcor.de> a �crit dans le message news: bvo6ai$cd4$1@news.mch.sbs.de... > > > I'm usi...

Problems closing GUI
I have created a gui and followed the steps in the help documentation, to output some variables to the workspace on the press of a button. I want to use this same button the close the GUI. The problem I have is when I pres the button, I get the following error; 'Attempt to reference field of non-structure array 'handles'.' And points me to 'On line 72 ==> varargout{1} = handles.output;' I'm assuming that the 'handles' variable is empty or deleted, hence the error. If I put a breakpoint before the 'close(gcf)' command, I can see the variables ...

multiple rollback points / savepoints
Hello all. I need to support multiple rollback points / savepoints and am wondering if there is some easy way to do this with berkeley. I used the terms rollback and savepoints, but I dont think my scenario is exactly like either... Specifically, I need to be able to run a batch type job that updates the db and at certain intervals commits its changes and associates those changes with an id (commit / savepoint / checkpoint id etc.) Say the job took 3 commits: commit1, commit2, and commit3. The job then fails and for whatever application specific reason, the db needs to be roll...

Tomcat and multiple SSL certs
Is it possible to setup multiple SSL based sites on Tomcat on one server?. I am investigating having multiple nic cards and adding an "address" attribute to map to each IP, I've not had much luck finding out how to get this done. Anyone have any feedback? thanks GM SSL is directly tied to the IP address, so you can't have https://site_a and https://site_b where both are on the same IP. I would try just plugging in both nic cards, get them both working on the o/s, then set up two connectors, both for ssl, with different address="..." attributes. Aside from the norm...

getting multiple line matches to single line for gcc --version
Im trying to use awk to extract the version of gcc in a makefile, but for now Im trying it on the command line to get it to work. Since the output of gcc --version is multiline, Im getting $3 of every line: 4.1.2 2006 free even for this: gcc --version | awk '{print $3}' How do I get it to just take the first line? Ive read the man page and it seems like I need to do something with RS= but Im unsure how to make it work. I thought setting RS="" or RS=" " would make it all a single line, but awk complains that I cannot set RS to either of those. Thanks for your ...

multiplication
I want to multiply two very long integers (say of 20 digits).I am storing them in character array.Then what mechanism should i follow to mutiply two such numbers.If anybody has any suggestions please post. On 30 Apr 2007 04:29:26 -0700, helPlease <devlinahello2@gmail.com> wrote: >I want to multiply two very long integers (say of 20 digits).I am >storing them in character array.Then what mechanism should i follow >to mutiply two such numbers.If anybody has any suggestions please post. Take a pencil and paper and multiply two four-digit numbers. Carefully show **every** step. ...

Two Axes
Hello, I need an plot, where the left and right axes relate to the same y-value, but have different ticks and labels (e.g. I need an energy on the left and the corresponding temperature on the right). has anyone solved this problem? Thanks! Regards, Alexander kemp@physik.uni-erlangen.de wrote: > Hello, > > I need an plot, where the left and right axes relate to the same > y-value, but have different ticks and labels (e.g. I need an energy on > the left and the corresponding temperature on the right). perhaps i've misunderstood the question, but try plotyy. l...

Multiple Edit Windows
Whenever I open multiple .m files each files is opened in a separate edit window. How do I get them all to open in the same edit window with tabs each for each file? Thanks, Marianne Hi, File -> Preferences -> Editor/Debugger -> Display -> Opening files in editor -> Single window contains... J�r�me J�r�me wrote: > > > Hi, > > File -> Preferences -> Editor/Debugger -> Display > -> Opening files in editor -> Single window contains... > > J�r�me > That's true for version 6.5 but not in 7.3 which is what I'm running. Thanks a...

GUI & EXE file
Hi, I'm an entry-level user of Matlab. I've created a .m file that calculates some performance about a car (this .m file is composed by some simple operations and by ode45 function) and now I need to create an exe file with a gui that allows you to give some inputs data needed to calculate the results. I just want to know if I can create a GUI in Matlab (with the "guide" command) and then I can create a Stand-alone software (exe file) always with Matlab (or maybe I have to use Visual Basic to create the GUI?) thanks a lot and apologize me for my english, I'm not an engl...

OS X and multiple logins
A few years ago I read the following thread concerning multiple log-ins with OS X... Does OS X allow this? I know Unix lets multiple concurrent desktops to be started. Does OS X? -------------------------------------------------------- Paul McGrane wrote: > In article <68480990.15242133@htan.org>, kayners@htan.org wrote: > > Tim Larson,tim@r5i.com,Internet writes: > > >Does anyone know if MacOS X is expected to support remote > > >terminals? > > You mean like NetBooting? If so, the answer is, "Yes." > Netbooting still requires a full fled...

using && to test true with multiple conditions
In bash if we use && to execute the right hand side, if the left side is true: e.g. echo "true" && true Can I combine this with another command which is not true? In simple terms i want to run 2 commands, and only execute the action, if command1 returns true and command2 returns false, on one line without any if statements, how do I do that? ie <command1 is true>AND<command2 is false><execute action> thankyou for any help. On Feb 3, 7:44=A0am, brumik <brum...@gmail.com> wrote: > In bash if we use && to execute the right h...

problem with selection in GUI
We are currently using a 'selectdata' function in our GUI program. We want to use pushbutton to activate the function to select points from a axes.But after we clicked the button,it said "error in figure:requested figure handle use in another object". Can anyone tell us what may be the problem? Cheers "Ye " <volkswagen.xu@gmail.com> wrote in message <h6b02n$dma$1@fred.mathworks.com>... > We are currently using a 'selectdata' function in our GUI program. > We want to use pushbutton to activate the function to select points from a > axes....

multiple regression: multiple years and multiple variables
Dear all, I am somewhat unexperienced in spss, so this question may seem simple to most of you, but I still want to ask it since I could not find the answer anywhere. I have a dataset consisting of yearly data on labor productivity growth for a 40 year period, for 16 countries in total. In the regression I want to make, this is to be the dependent variable. As independent variables I have several other economic data, also on all 16 countries and on the entire 40 year period, so my dataset is complete. My problem is now that it is of course quite easy to do a regression on each of t...

File browser in a GUI
Is there a way to create a file browser inside a GUI? I would like the user to be able to hit a button and bring up a folder window so they can browse for the file they want to open. Is this possible? I am sure that something like this has been done before so if anyone has a tutorial or a piece of code on the file exchange that shows this please let me know. thanks s. sivak wrote: > Is there a way to create a file browser inside a GUI? I would like > the user to be able to hit a button and bring up a folder window so > they can browse for the file they want to open. > > Is t...