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.

Dexters
  • 2,419
  • 6
  • 37
  • 57

2 Answers2

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.

H.Muster
  • 9,297
  • 1
  • 35
  • 46
  • 2
    I suggest a more robust approach for getting the handle to the scattergroup. Either select the scattergroup (click on the mouse button in the figure toolbar, then click on the group), and get the handle as `h = gco`, or use `findall` with some specific characteristic of the group, for example if the markers are circles, use `h = findall(gca,'marker','o')` – Jonas May 12 '12 at 14:13
  • @Jonas: Thanks for this interesting comment. Why don't you make it an answer to this question? You would get my up-vote for sure. – H.Muster May 12 '12 at 14:39
  • 2
    My answer would just be a slightly improved copy of yours. Just edit your answer. – Jonas May 12 '12 at 14:50
  • Then many thanks for your help. I just did the edits; just let me know if I got something wrong or forgot something. – H.Muster May 12 '12 at 15:07
  • Thanks ! This is exactly what I was trying. To get scatterobjects but unable to do so. I will try this out. – Dexters May 13 '12 at 05:40
  • and yes I was doing it through GUI SizeDat, but too many data points and it was inefficient. – Dexters May 13 '12 at 05:43
  • If the points were created using the `scatter` command they should belong to one large group and every change in `sizedat` should influence the whole group, shouldn't it? If they do not belong to one group, the `findall` alternative proposed by Jonas should be the right approach, I guess. – H.Muster May 13 '12 at 07:17
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.

Abhinav
  • 1,882
  • 1
  • 18
  • 34
  • Thanks . But the problem is i do not have the access to data. I just have the .fig file which is a result f a scatter command. So I dont have the X,Y to plot using the scatter() function. – Dexters May 12 '12 at 04:46
  • @user840546 please remember to close the question if the answer is correct. – Abhinav May 12 '12 at 10:36
  • @Abhinav: Tere is no closing of questions for correct answers, but accepting them. – Jonas May 12 '12 at 13:04
  • @Abhinav yeah I though about this approach but the figure has too many data points and the above approach i thought would be slow for my case. Thanks for you efforts ! – Dexters May 13 '12 at 05:42