Changing the transparency of a plot line, saved in a fig file
조회 수: 38 (최근 30일)
이전 댓글 표시
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%.
댓글 수: 0
채택된 답변
Adam Danz
2019년 11월 5일
편집: Adam Danz
2019년 11월 5일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!