Change to default line colors
16 views (last 30 days)
Show older comments
Siddharth Murpani
on 21 Mar 2021
Answered: Cael Warner
on 21 Mar 2021
I have a saved .fig file in one of my directories, I have managed to import the fig file as an object in the workspace with f = openfig(path). The figure currently uses a custom line coloring scheme, is there any way I can revert back to the default line coloring by manipulating the properties of the object?
I tried changing the Children of the Axes property but it seems to only change the color of a single line at once, I am trying to do it for all children of this property at once.
0 Comments
Accepted Answer
Cael Warner
on 21 Mar 2021
This worked for me. it will produce a random blank figure which is used to find the default 'colorOrder'. It then replaced the colorOrder of the figure I had saved and opened.
fig_name='random_figure.fig';
figure;
x=1:10;
y1=x; y2=2*x;y3=3*x;
plot(x,y1,'r',x,y2,'b',x,y3,'k');
legend('y1','y2','y3');
saveas(gcf,fig_name);
figure;
def_clr_order=get(gca,'colorOrder'); % called before plotting anything, just to find the default color order
f = openfig(fig_name);
plts = allchild(gca);
for i=1:length(plts)
set(plts(i),'Color',def_clr_order(i,1:3));
end
Output:
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!