Bizare problem with FaceAlpha and rendering
13 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a very strange problem so i want to create a series of patch objects and plot them together (for simplicity in this example there is only one object):
X =900000;
Y =115;
Z =100;
origin = [100000,5,100];
MINX = 0.1;
MAXX = 1000000;
MINY = 0.000001;
MAXY = 120;
MINZ = 0.01;
MAXZ = 1000;
clf
h(1) = axes('Position',[0.2 0.2 0.6 0.6]);
vert = [origin(1) origin(2) origin(3); ...
origin(1) origin(2)+Y origin(3); ...
origin(1)+X origin(2)+Y origin(3); ...
origin(1)+X origin(2) origin(3); ...
origin(1) origin(2) origin(3)+Z; ...
origin(1) origin(2)+Y origin(3)+Z; ...
origin(1)+X origin(2)+Y origin(3)+Z; ...
origin(1)+X origin(2) origin(3)+Z];
fac = [1 2 3 4; ...
2 6 7 3; ...
4 3 7 8; ...
1 5 8 4; ...
1 2 6 5; ...
5 6 7 8];
hold on;
bob = patch('Faces',fac,'Vertices',vert,'FaceColor','b','FaceAlpha',0.5);
light('Position',[1 3 2]);
light('Position',[-3 -1 3]);
material shiny;
alpha('color');
alphamap('rampdown');
camlight(45,45);
lighting phong;
view(30,30);
set(gca,'XLim',[MINX MAXX],'YLim',[MINY MAXY],'ZLim',[MINZ MAXZ]);
set(gca,'XScale','log','YScale','log','ZScale','log');
%set(gcf, 'Renderer', 'OpenGL');
Ok so the issue is that up until the point where i set the scales to log the objects are semi transparent (FaceAlpha 0.5), however when set they then become solid again and no matter what value of FaceAlpha they remain this way.
I looked around and found a suggestion to set the rendering to open glide (last line of code which is commented) but this is when it becomes even more strange. If you run the code with the last line above you do get transparent objects but the log scales change completely and appear to be normal scales again despite being set to log values!
Can anyone help me with this? I need to get transparent objects with the log scales obtained with the code above (minus the openGl render code which changes the log scale)
Also has anyone encountered this problem before? Why on earth would changing the renderer change the log scale of the plot???
Thanks
Matt
EDIT: BTW im using r2008b EDIT: OK so i just found that openGl doesnt support log scales so thats one problem sorted but how then can i get transparent objects with log scales in matlab??
0 个评论
采纳的回答
Desiree
2011-8-10
Unfortunately you won't be able to create a plot with log scales and transparent objects.
OpenGL is the only renderer that supports transparency, but it does not support log scales. The other renderers (ZBuffer, Painters) do support log scales, but no transparency. You can find more information on renderers here:
6 个评论
Oleg Komarov
2011-8-10
@Desire: update to the graphics engine when? Will it include also upgrades to the customization of the axes?
更多回答(3 个)
W Perkins
2013-2-7
编辑:W Perkins
2013-2-7
Depending on the complexity of your object, you could try logarithmically transforming your data, plotting, and changing the scale labels (not the scale itself), and the transparency function is preserved. For example:
duration = [0.2 1 10 60 300 600 1200 1800 3600]; %sec
x = log(duration);
y = 9:-1:1;
patch([x fliplr(x)],[y -fliplr(y)],[1 0 0],'edgecolor','none','facealpha',0.5)
set(gca,'xtick',log(duration))
labels=num2cell(duration);
set(gca,'xticklabel',labels)
0 个评论
Felix
2014-12-28
Hi, if you use the latest version of MATLAB (2014) you can also tune up the ticklabels so they are displayed as 10^... by using latex strings.
powers=-10:1:10;
a=cell(length(powers));
for i=1:length(powers)
a(i)=cellstr(strcat('10^{',num2str(powers(i))));
a(i)=cellstr(strcat(a(i),'}'));
end
set(gca,'YTick',log10(10.^powers));
set(gca,'YTicklabel',a);
a than is a cell array containing Strings like 10^{-10}, 10^{-9}, ...
now you have a logarithmic scale and transparency!
0 个评论
himura
2022-9-24
编辑:himura
2022-9-24
Pretty old question, it is 2022 now and this still seems to not be supported (please correct me if I am wrong).
I am here to pitch another workaround: 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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!