This question already has answers here:
Retrieving X and Y values from Matlab Plot
(4 answers)
Closed 9 years ago.
I'm developing a GUI in Matlab that presents a plot (in an axis object). When clicking on a point in the plot, the GUI will open some other plots for that data point.
I added an axis object to my figure and implement the WindowButtonDownFcn to get a button click. I can get the mouse position with
pos=get(hObject,'CurrentPoint');
but how do I convert it to values in my plot? (i.e. which x-value was clicked on)
thanks.
(I'd be happy to hear if there is some simpler way to do this, instead of writing my own GUI)
Try looking up the help on ginput and then set that to some variable. Then plot the points for the number of ginputs you've done.
A lot of it is explained here: http://www.mathworks.com/help/techdoc/ref/ginput.html
Related
This question already has an answer here:
How to hide the lines of a graph in MATLAB so that they do not extend beyond the frame
(1 answer)
Closed 1 year ago.
As you can see in the attached image, the line of the graph hangs over the axis, how can I make it not hang over the axis?
A simple approach could be to call something like
ylim([min(y(:))-0.02*range(y(:)) Inf]);
after plotting your data y. The 2% margin may be adjusted to your tastes.
This question already has answers here:
Plot circles with alpha values in MATLAB
(5 answers)
Closed 8 years ago.
I have a plot similar to the one below. This is a cylindar. The points near the axis are red and become more and more blue when they get far from it.
The problem is that the blue points completely hide the red ones.
Is there any way to make these blue points transparent enough to see what's inside?
I could suggest a hack to try. Given that you approximately know what the colors of the points you want to remove are, you could use findall or findobj to extract the line objects from your plots (maybe they're named something else in a 3D plot, don't have a lot of experience there) and then just delete those with the blue coloration.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Points moving along a curve within MATLAB
I have two arrays ,the first represents the x-axis values and the second represents the y-axis values of a certain curve. I want to draw a point (or some object) that moves along that curve in MATLAB.
You can just trace the curve, i.e., you can place the cyrsor on the curve and press left or right to move your cursor across it.
This question already has an answer here:
Print Plot in Octave in Background
(1 answer)
Closed 9 years ago.
I need to create an ocatve script which will generate a 2D-plot and then directly export it as image without actually plotting it.
Hypothetical Example:
x=1:10;
exportDirectly(x,'myImage.jpg');
Is this possible?
You can create a figure, but turn of visibility. Then plot and save as usual.
something like
fh = figure()
fh.set('Visible','Off')
%Some Plotting here
print(fh)
That might be of some help...
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How do I edit the axes of an image in MATLAB to reverse the direction?
Hey guys,
In MatLab I have a pair of axes where the y-axis starts from (0,0) and counts up to (0,100) with tick marks on this x-axis going 0,1,2,...,100. Can a flip it so it goes 100,99,...,0 so the origin would be (0,100)? Any ideas? I know it's possible because I've seen graph figures like this.
set(gca,'YDir','reverse'); before you draw the graph. Thanks to gary comtois's link - stackoverflow.com/questions/2865600/