Fill transparency with log x axis

8 次查看(过去 30 天)
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

更多回答(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 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by