问题
I am running Octave 3.4.0 and want to create a transparent surface plot. However, I have not been able to do so when messing around with facealpha
, edgealpha
, alphadata
and alphadatamapping
.
Example code for creating a non-transparent surface:
p = peaks(40);
f1 = figure(10);clf
s1 = surface(p)
view(3)
xlabel('x');ylabel('y');
hold on;plot3([0 40],[40 0],[-10 10],'k')
set(s1,'edgecolor','none')
set(s1,'facealpha',0.2)
The result of this given in the image below. As you can see, the line drawn diagnonlly at the start is hidden behind the surface, even though the surface is suppose to be semi-transparent. Is this a bug in my version of Octave, or have I missed something?
回答1:
This works for me on Octave 3.6.2 using gnuplot as the graphics toolkit. So you better upgrade your Octave installation.
Two things to note though:
- the part of the diagonal line that goes behind the surface is not drawn in a lighter so it still looks weird;
- with the new experimental fltk graphics toolkit, it doesn't work at all.
回答2:
I agree with Vidar: his code doesn't work with latest Octave 3.8.1 (Cygwin 1.7.30(0.272/5/3) setup_x86_64.exe:2.850 xterm 305-1 Gnuplot 4.6.3-3). facealpha just makes surf of lighter color. One workaround however, is that mesh
command in octave has a feature of throwing away the faces: hidden
(manual).
So
p = peaks(40);
f1 = figure(10);clf
s1 = mesh(p)
view(3)
xlabel('x');ylabel('y');
hold on;plot3([0 40],[40 0],[-10 10],'k')
hidden('off')
produces
回答3:
This actually worked for me in Octave 5.1.0 but the order of commands is important. You need to set the alpha BEFORE plotting the line. Try just the surface on it's own and play with the alpha - it works:
>> s1 = surface(p)
s1 = -2.7876
>> view(3)
>> set(s1,'facealpha',0.5)
>> colormap jet
>> grid on; % so you can see the grid through the transparent surface:
Surf with transparency
来源:https://stackoverflow.com/questions/12072412/setting-transparancy-of-surface-plot-on-octave