我有一个日志日志记录3D图,其中我用表面拟合了一些数据。我疯狂地为表面提供一些透明度,以便在下面看到我的数据。这是一个最小的例子,我生成一些随机日期,我做幂律适合,在对数刻度变成一个平面。有什么建议吗?我基本上想要一个透明的灰色表面。我阅读了手册,使用FaceAlpha但没有工作。谢谢。甲
%generate a vector of X and Y variables
[Log10X,Log10Y] = meshgrid(1.1:0.1:2);
Log10X = reshape(Log10X,100,1);
Log10Y = reshape(Log10Y,100,1);
%Specity Z as a function of X and Y (i.e. it lays on a plane)
A=0.3; B=0.4;
Log10Z =A*Log10X + B*Log10Y;
%%Add in a noise vector
noise =0.02*randn(100,1);
Log10Z= Log10Z + noise;
%compute "original" X,Y,Z
X = 10.^Log10X;
Y = 10.^Log10Y;
Z = 10.^Log10Z;
figure
scatter3(X,Y,Z, 'filled')
hold on
f = fittype( @(a, b, c, x, y) a*x.^b.*y.^c, 'independent', {'x', 'y'}, 'dependent', 'z');
[sf,gof] = fit( [X, Y],Z,f,'startpoint', [0.9 0.3 0.4] ) %, 'Robust', 'LAR'
XLIM = [min(X) max(X) ]
YLIM = [min(Y) max(Y) ]
HANDLEsur = plot(sf,'XLim',XLIM,'YLim',YLIM )
set(gca,'xscale','log','yscale','log','zscale','log')
xlim(XLIM)
ylim(YLIM)
set(HANDLEsur,'EdgeColor','none','FaceColor',[0.5 0.5 0.5],'FaceAlpha',0.3)
编辑: 试图做一个建议的解决方法,但对于3D绘图来说这看起来很复杂,对于2D绘图你可以做到这一点,但它不适用于3D:
%replace linear XTickLabel with log XTickLabel
set(gca, 'XTickLabel',[]) %# suppress current x-labels
xt = get(gca, 'XTick');
yl = get(gca, 'YLim');
str = cellstr( num2str(xt(:),'10^{%d}') ); %# format x-ticks as 10^{xx}
hTxt = text(xt, yl(ones(size(xt))), str, ... %# create text at same locations
'Interpreter','tex', ... %# specify tex interpreter
'VerticalAlignment','top', ... %# v-align to be underneath
'HorizontalAlignment','center'); %# h-aligh to be centered
答案 0 :(得分:3)