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...
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:
Is it possible to change markers in Matlab plot function? [duplicate]
(1 answer)
Custom Markers for Matlab plot
(1 answer)
Closed 3 years ago.
I know in MATLAB, the marker plot only like this table.
How to make the other marker plot symbol? Like "love" marker? '♡'? This is my code
clear all;
clc;
x=[1,2,3];
y=[3,2,1];
plot(x,y,'b♡','markerfacecolor','y','markersize',15);
grid on;
The 'b♡' give an error in the MATLAB because the '♡' symbol does not exist
This question already has answers here:
How to imshow with Invisible figure in MATLAB running on Linux
(3 answers)
Closed 4 years ago.
How to get the imshow and imshowpair result as a .bmp image while hiding the imshow and imshowpair? Because I'm running my program in background which is integrated with another program. So i don't want to display the imshow result but I need to save that result to a folder.
figure(1);
imshowpair(registered,img2);
viscircles(centres,radii);
title('Registration','fontSize',12)
figure(2);
imshow(img2);
viscircles(centres,radii);
saveas(2,'Registered.bmp');
Just set the figure visibility to false. E.g.
fig = figure('visible','off');
imshow(img)
saveas(fig,'img.png')
This question already has answers here:
Turn a MATLAB plot into image
(2 answers)
Save a plot in Matlab as a matrix [duplicate]
(2 answers)
How can I save an altered image in MATLAB?
(8 answers)
How do I save a plotted image and maintain the original image size in MATLAB?
(1 answer)
Closed 5 years ago.
Suppose you have one image.
You plot this image.
After that, you plot a green tracing on top of that image.
You make this plot easily using the plot function.
After this initial plot, you add a second tracing on top of the same image.
Therefore you have a figure with two plots just like in this image.
How can I store the result of this multiple plots to one variable without saving to file and then reading the final result?
I can do this if I print and then read the image but I want the same result without having the additional step of saving to file.
Any clue?
Example code and figure:
imshow(a)
hold on
plot(centroidsFiltered(:,2),centroidsFiltered(:,1),'.g','LineWidth',0.5)
plot(int32(centroidsFiltered(i,2)), int32(centroidsFiltered(i,1)), '.g', 'MarkerSize',20)
The data resulting from the plot is this figure.
How can I store all the resulting information to one variable?
Data can be downloaded here: https://expirebox.com/download/c95e9a0e5ac5530729f6960679ec9733.html
CLARIFICATION
What I want as an output variable from this plot is the original image matrix, with the update in the matrix positions where the green line and the green marker is perceptible.
You could try using getframe. See Documentation
imshow(a)
hold on
plot(centroidsFiltered(:,2),centroidsFiltered(:,1),'.g','LineWidth',0.5)
plot(int32(centroidsFiltered(i,2)), int32(centroidsFiltered(i,1)), '.g', 'MarkerSize',20)
b = getframe(gca);
To recreate the plot:
figure;
imshow(b.cdata)
Note: That the size of b.cdata and a will not be exactly the same. Since this is a screen grab of the axis b will most likely have some extra pixels around the border. However, with a careful setting of units to pixels and using the optional rect input to getframe you may be able to get the output dimensions correct.
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