필터 지우기
필터 지우기

Fill transparency with log x axis

조회 수: 16 (최근 30일)
Stephen Faul
Stephen Faul 2011년 8월 10일
편집: himura 2022년 9월 24일
Hi all,
I am trying to make a plot with three semi-transparent fill areas. I require a log x-axis. It's not a problem getting this to work on a linear axis but the transparency disappears when you change to a log scale. Try:
figure;
theAxis = gca;
set(theAxis,'NextPlot','add');
%plot three shapes
t = (1/16:1/8:1)'*2*pi;t = t';
for i=1:3
x = sin(t)+i;
n = cos(t)+i;
h = fill(x,n,'r');
set(h,'FaceAlpha',0.5);
end
%pause to view
pause(2);
%now change to log scale on the x-axis and the transparency disappears
set(theAxis,'XScale','log');
pause(2);
%and change back and the transparency reappears
set(theAxis,'XScale','linear');
Any ways to get the transparency to work on a log scale plot? Thanks, Stephen

채택된 답변

Stephen Faul
Stephen Faul 2011년 8월 10일
  댓글 수: 2
Marshall Borrus
Marshall Borrus 2020년 12월 15일
lies.
himura
himura 2022년 9월 24일
do you have a solution @Marshall Borrus?

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

추가 답변 (1개)

himura
himura 2022년 9월 24일
편집: himura 2022년 9월 24일
Pretty late, but for any future perspn looking at this, the accepted anser basically says "it is not supported, here's a work around"
I am here to pitch another workaround, which is to simply setting the color to be lighter. The example code here is for semilogy(), but it works for semilogx() and loglog()
x_axes = -10:0.1:10;
y_axes = x_axes .^ 2;
semilogy(x_axes, y_axes, '*', Color = [0 0 1]); % without transparency
semilogy(x_axes, y_axes, '*', Color = [0.7 0.7 1]); % with "transparency". it only seems transparent, but not really
% or
semilogy(x_axes, y_axes, '*', 'Color', [0 0 1]); % without transparency
semilogy(x_axes, y_axes, '*', 'Color', [0.7 0.7 1]); % with "transparency". it only seems transparent, but not really

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by