How can I get the plot for a saved figure?
Show older comments
Hello,
Long ago I've saved a figure with 50 sets of points (only 15 could be shown in the legend below). Now I want to edit the marker size of the data, but I don't want to select all the 50 sets by hand. Is there any other way to do it? People often use the variable p as in this command:
x = 1:10;
p = plot(x,x^2,'-k*', x,x^3,'-ko', x,x^4,'-k' )
p(1).MarkerSize = 20;
p(2).MarkerSize = 12;
However, as I am using a saved figure, I don't have this p variable. Is there another way of getting it? If there was a command 'gfc' (get current figure) but for the data itself it would be of great help to me.

Accepted Answer
More Answers (2)
"If there was a command 'gfc' (get current figure) but for the data itself it would be of great help to me."
Open the .fig file in matlab. Use the white arrow tool ("Edit Plot") to select a single data point to make that set of data active.

Then go to the command window and type
h = gco; %get current object handle
Then you can change the object properties such as markersize.
h.MarkerSize = 20;
2 Comments
Martim Zurita
on 25 Apr 2019
Adam Danz
on 25 Apr 2019
Yeah, with 50 objects, Rik's solution is definitely better.
Steven Lord
on 4 Oct 2020
If you need to find the handles to all items that have a specific property (like MarkerSize or SizeData) calling findobj (or findall) with the '-property' option and the name of the property will give you the handles of all the objects with that property.
h = plot(1:10, 's-'); % Has a property MarkerSize but not SizeData
hold on
h2 = scatter(1:10, 10:-1:1, 25); % Has a property SizeData but not MarkerSize
objWithMarkerSize = findobj(gcf, '-property', 'MarkerSize'); % line h
objWithMarkerSize.MarkerSize = 20;
objWithSizeData = findobj(gcf, '-property', 'SizeData'); % scatter plot h2
objWithSizeData.SizeData = 100;
3 Comments
Martim Zurita
on 4 Oct 2020
Adam Danz
on 4 Oct 2020
@Martim, Rik's answer also uses findobj. Steven Lord's answer is different from Rik's in two ways.
- He uses -property instead of type. As SL states, -property has a wider span than type since many classes have the same properties.
- He mentions findall which can access handles with HandleVisibilty set to off.
For comparison, my answer is a manual approach that requires the user to manually select objects by clicking on them whether their handles are visible or not (but requires that the object itself is visible). If object selection should be programmatic, Rik's or Steven Lord's answers are the way to go. If the object selection should be manual, you could use any of the approaches here but if only a few objects are needed, somtimes clicking on them is easiest.
Martim Zurita
on 5 Oct 2020
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!