Changing the transparency of a plot line, saved in a fig file

27 views (last 30 days)
Hi,
I'm trying to make some changes to some graphs that I already saved as a picture. I have the Fig.-File an when I open it one of the lines that was 50% transparent when I saved it is full opaque now. Is there a way to access the individual plot handels afterwards?
I tried changing the color in the plot edior but nothing changes even when I change the transparency to 100%.

Accepted Answer

Adam Danz
Adam Danz on 5 Nov 2019
Edited: Adam Danz on 5 Nov 2019
Manually edit each line object
The easiest method would be to open the fig file, use the pointer to select the line you'd like to edit so that it is the current object, and then execute this line of code in the command window. 0.5 is the transparency level between 0 (invisible) and 1 (opaque).
set(gco, 'Color', [get(gco,'Color'), 0.5])
Programmatically edit all line objects on the axes
Another method is to get the handle from the axes programmatically but then you have to add additional steps to isolate the handle you'd like to change. If you'd like to set the transparency of all objects on the axes, select the axes so it's the current axis and then run this line from the command window. Again, 0.5 is the transparency level.
% Transparency level of all objects > > > > > > vvv
set(get(gca,'Children'),{'color'},cellfun(@(x)[x,0.5],get(get(gca, 'Children'),'color'),'UniformOutput',false))
The reason why the transparency levels aren't saved in the figure
The reason the transparency level doesn't appear when opening the figure is because this 4th element of the color vector is undocumented and isn't saved when saving the figure.

More Answers (0)

Categories

Find more on Graphics Object Properties 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!