Official transparency support for figures (savefig does not preserve transparency)

It appears that savefig still does not support transparency in R2022a. Is there any alternate scheme or any plan to offficially support transparency and allow figures as generated to be truly saved?

댓글 수: 4

Are you sure you mean savefig? savefig creates a struct that refers to the figure object and then save() the struct to a fig file. A fig file is a mat file. So savefig should store an exact copy of the serializable portions of the graphic objects.
It would make more sense if you were talking about saveas()
Yes. Neither savefig nor saveas generates an exact copy of the figure as displayed. As an example, the following code saves a figure with transparency and then reopens it. The saved figure has all transprency scrubbed out.
clear; close all;
x = linspace(0,2*pi);
y = sin(x);
% Original Figure
f1 = figure(1);
plot(x,y,'Color',[0 0 0 .1],'LineStyle','-','Marker','.');
% Saved Figure
savefig(f1, 'test.fig')
f2 = openfig('test.fig');
The Color property is only expecting an RGB triplet, not an RGBA quadruplet .Refer the following document: https://www.mathworks.com/help/matlab/ref/plot.html#btzitot-Color.
The Line class do not support to store alpha values in its Color property even though it clearly processes them when given. You can always add in the alpha values again by manually setting the Color property of the cloned figure (f2.Children.Children.Color = [0 0 0 0.1]). Note that the Color property will have the value [0 0 0] after running that command, but the plot will be updated with the correct alpha value.
clear; close all;
x = linspace(0,2*pi);
y = sin(x);
% Original Figure
f1 = figure(1);
plot(x,y,'Color',[0 0 0 0.1],'LineStyle','-','Marker','.');
savefig( f1, 'test.fig')
f2 = openfig('test.fig');
f2.Children.Children.Color = [0 0 0 0.1];
If you have any follow-up question please feel free to reply back or contact our support team.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2022년 9월 11일

댓글:

2022년 9월 19일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by