Fill transparency with log x axis

9 ビュー (過去 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 Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by