3

I have a figure file (scatter.fig) . This figure has many scatter points plotter using scatter(). Now i just have this fig file, I need to increase the marker size of all scatter points. Tried it manually but its very difficult. Is there a way i can do something like H=figurehandle() s= points(h) set(s,'markersize');

I just could not figure out the exact commands.

Thanks.

4

2 に答える 2

6

You need to get a handle to the scattergroup object to change the marker properties. As proposed by Jonas in a comment, you can get it easily by

   % get handle to scattergroup object
   h = gco;

Since the scatter group is a child of the axis, you could also get it by

% get handle to scattergroup object
h = get(gca,'children');

If the image contains more than one graphic object (e.g., additional lines), the command findall maybe of help (again a suggestion by Jonas). With this command you can search for handles to graphic objects with specific properties:

h = findall(gca,'marker','o')

When you have a handle to the scattergroup, you can change the properties of the marker by

% change size of markers 
set(h, 'sizedata', 50)

To see a full list of scattergroup properties that can be changed use

get(h)

or for a GUI that shows the properties use

inspect(h)

If you just want to edit a single plot (i.e. no need for scripting), you can just edit the actual figure by clicking on the mouse button on the toolbar and then clicking on one marker in the plot (again suggested by Jonas). Then you right-click on the marker, select "Properties", then you push the button "More properties". In the UI that opens up you change the entry "sizeData" to a value of your choice.

于 2012-05-12T11:45:56.310 に答える
2

EDIT:1 In case, the X and Y data are not available

I tried to find the handle for markersize, but I couldn't. So, I devised an alternate way. If we have the figure file, then we can directly get the X and Y data from the figure, and replot the figure using scatter with new marker size. Here is the code below.

clear all
X=rand(100,1);
Y=rand(100,1);
scatter(X,Y,10) 
saveas(gcf,'SO_scatterQ.fig')
clear all
close all
%%%%%% THE CODE ABOVE JUST GENERATES A SCATTER .fig FILE WITH BLACKBOX PROPERTIES %%%%%
openfig('SO_scatterQ.fig')
Xdata_retrieved = get(get(gca,'Children'),'XData');
Ydata_retrieved = get(get(gca,'Children'),'YData');
scatter(Xdata_retrieved,Ydata_retrieved,20) % You can use any other marker size you wish to use

Although, I would welcome if anyone posts an answer to directly get the handle for the markersize property.

于 2012-05-12T04:38:58.300 に答える