I have been trying to Create a program with the GUI in MATLAB. When I try to plot information with AXES I can not figure out how to do it. I know about the function plot, but I need to be able to re-size and move the plot around in the figure so I can make room for the input uicontrol. I am not sure what to do. Please help.
There are a couple of different ways to tackle this problem. But the way I always choose to do so, is:
hold on:
plot(...), xlim([xmin xmax), ylim(ymin ymax])
This should set your bounds on the axis.
I don't have Matlab at hand right now, but try the following:
To set size of the plot axes inside the figure window use
set(gca,'Position',[left bottom width height])
see Mathworks' site on axes properties
Related
I tried using axes for displaying images in Gui.But, before displaying any images, the axes is shown with a plot figure while running the GUI, something like below.
You can see the default axes being displayed. Is there a way to display the axes in running GUI without displaying these plot figures? So that when the image is not displayed in the axes, nothing is displayed. Thanks in advance.
UPDATE 1
I have used 9 axes here, thus the long trail of y axis.
Yes, you can use
axis off
To remove the axes from the empty plots. Then use
axis on
When you actually plot something to bring them back.
Best,
I am new to GUI. But I have two axes in GUIDE GUI and wish to specify the one to plot a figure, but I can't find handles.axe1 anywhere. Can anyone help me with this?
Since you built your GUI with GUIDE you can easily access the Tag property of each axes in the property inspector.
Once you know the tag of each axes, you can choose where to plot stuff using the first argument of plot:
plot(TagofAxes,x,y)
or using imshow, using the Parent property:
imshow(YourImage,'Parent',TagofAxes)
and so on.
I'm creating a simple GUI in MATLAB and I'm trying to create a figure that contains a 2d plot on an axes, all is working well, but I have a rough time trying to figure out how to fix the position of the axes/plot.
The axes seems to scale with the figure window size. If I maximize the figure on my screen, the axes is maximized within, etc. What I want to accomplish is to have a row of buttons beneath the plot on the same figure as the plot, basically an area of 50 (ish) pixels tall that the plot does not encroach on. I know how to do this in HTML, but I can't figure out a good way in MATLAB.
Any alternative approaches would also be greatly appreciated.
Change the units of the axes to anything other than 'normalized', like 'pixels'. Then it won't automatically resize with the figure. From this documentation page:
When you create a graph, MATLABĀ® creates an axes to display the graph. The axes is sized to fit in the figure and automatically resizes as you resize the figure. MATLAB applies the automatic resize behavior only when the axes Units property is set to normalized (the default).
Use set(gca,'Position',pos) where pos = [x y w h] to set the position and size of the axes in the units you chose.
See this answer for an example and a function for holding an axis size once you have it in place.
I'm now using MATLAB R2012b. I want to draw a grey rectangle together with the axes, and want the rectangle to be behind the axes. I tried
uistack(gca,'top');
but nothing happens.
In this article they mentioned that
However, it is possible to place axes objects on top of UIPANEL
objects (which were introduced in MATLAB 7.0 (R14)).
So I think there should be some way to do that.
Try the following:-
set(gca, 'Layer', 'top')
Ref: Draw Matlab graphs with frame, ticks, on top of graph lines
I draw images to axes in my matlab UI, but I don't want the axes and ticks to be visible how do I prevent that, and also where do I make this call?
I do this
imagesc(myImage,'parent',handles.axesInGuide);
axis off;
Is this what you are looking for?
This is definitely somewhere else on this website and in the matlab documentation. Try typing
help plot
Or using the documentation on plotting!
edit: Now that you have shown what you are doing. (You don't need the handles, I just always write them in to clutter my workspace)
myImage = yurbuds0x2Dironman; # don't ask
fH = figure;
iH = imagesc(myImage);
set(gca,'xtick',[],'ytick',[])
Are you able to do it like this?
I support the
set(gca,'xtick',[],'ytick',[]);
approach over the
axis off
one. The reason is set(gca, ...) just removes the labels but keeps the axes, unlike axis off. I am generating a group of images with fixed dimensions to combine later into a video. Deleting the axes creates different size frames that can't be recombined.