曲线图matplotlib的彩色立方体 [英] Graph a colored cube in matplotlib

查看:2720
本文介绍了曲线图matplotlib的彩色立方体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在一个统计code,生成各种图表用Matlab的。图表类型包括从简单的饼图和条形图到3D直方图格。

现在我们想一个漂亮的图形界面去与软件。我们有一个原型Matlab的图形用户界面,但Matlab的GUI有一些问题,所以我们想搬到一个更强大的图形用户界面。我最好的选择似乎是PySide + matplotlib,但到目前为止,我还没有找到一种方法来绘制3D点阵。在MATLAB code使用contourslice。似乎没有要在matplotlib了类似的电话。所以,任何人都可以帮我找出我怎么可能会得到这样的图,matplotlib?到目前为止,我唯一的想法就是图表6的表面,使一个立方体。

其实,对于其他GUI推荐/图形库的组合也欢迎。该基地的统计code是C ++,所以Python只是众多选项之一。一些我所见过的StackOverflow的答案来看,matplotlib可能会在3D太慢。也许R.将是更好?

下面是在MATLAB code:

  CLF
×10 = -1.800000e + 01;
XHI = 1.000000e + 01;
YLO = 1.000000e + 01;
YHI = 3.000000e + 01;
ZLO = -1.000000e + 03;
志= 1.000000e + 03;
X =零(16,16,16);
Y =零(16,16,16);
Z =零(16,16,16);
V =零(16,16,16);
%在X,Y,Z,和V填补大量的文本
XT = [-1.800000e + 01:2.800000e-01:1.000000e + 01];
YT = 1.000000e + 01:2.000000e-01:3.000000e + 01];
ZT = [-1.000000e + 03:2.000000e + 01:1.000000e + 03];
isoval = -1.428280e + 01;
H =补丁(等值面(X,Y,Z,V,isoval),...
FaceColor,蓝,...
EdgeColor','无',...
'AmbientStrength',0.2,...
'SpecularStrength',0.7,...
DiffuseStrength',0.4);
isonormals(X,Y,Z,V,H);
补丁(isocaps(X,Y,Z,V,isoval),...
FaceColor,插值,...
EdgeColor','无');
轴([×10 XHI YLO YHI ZLO志])
daspect([2.800000e + 01,2.000000e + 01,2.000000e + 03])
集(GCA,线宽,2)
集(GCA,粗细,大胆)
设置(GCA,字号,12)
网格
框
颜色表(默认);彩条

视图(3)
集(GCF,渲染,zbuffer)
照明蓬
CIN ='N';
如果(CIN =='Y')
鑫= questdlg('轴滑动过来吗?','轴','X','Y','Z','X');
鑫=低(XIN);
对于i = 1:101
如果GCF〜= plotFigure
返回
结束
如果(鑫=='Y')
H = contourslice(X,Y,Z,V,XT(i)中,[],[],101);
ELSEIF(鑫=='X')
H = contourslice(X,Y,Z,V,[] YT(i)中,[],101);
ELSEIF(鑫=='Z')
H = contourslice(X,Y,Z,V,[] [],ZT(i)中,101);
结束
轴([ -  1.8000e + 01 1.0000e + 01 1.0000e + 01 3.0000e + 01 -1.0000e + 03 1.0000e + 03 -8.6774e + 01 4.2066e + 02])
集(GCA,线宽,2)
集(GCA,粗细,大胆)
设置(GCA,字号,12)
网格
框
视图(3)
集(H,线宽,10)
彩条
暂停(0.3)
如果(ⅰ&其中; 101)
CLF
结束
结束
结束
 

解决方案

您可能想看看的 Mayavi的 如果您使用的是Windows,它自带默认与的Python(X,Y)

I work on a statistical code that generates a variety of graphs with Matlab. The graph types range from simple pie and bar charts to 3D histogram lattices.

Now we would like a nice GUI to go with the software. We have a prototype Matlab GUI, but Matlab's GUI has a number of issues, so we'd like to move to a more robust GUI. My best option seems to be PySide + matplotlib, but so far I haven't found an way to plot the 3D lattice. The matlab code uses contourslice. There doesn't seem to be a similar call in matplotlib. So, can anyone help me figure out how I might get a graph like this with matplotlib? So far my only idea is to graph 6 surfaces to make a cube.

Actually, recommendations for other GUI/Graph library combinations are also welcome. The bases stat code is C++, so Python is just one of many options. Judging from some of the answers I've seen on StackOverflow, matplotlib may be unacceptably slow in 3D. Perhaps R would be better?

Here's the matlab code:

clf
xlo = -1.800000e+01; 
xhi = 1.000000e+01; 
ylo = 1.000000e+01; 
yhi = 3.000000e+01; 
zlo = -1.000000e+03; 
zhi = 1.000000e+03; 
X=zeros(16,16,16);
Y=zeros(16,16,16);
Z=zeros(16,16,16);
V=zeros(16,16,16);
% fill in X, Y, Z, and V  huge amount of text
xt = [-1.800000e+01:2.800000e-01:1.000000e+01];
yt = [1.000000e+01:2.000000e-01:3.000000e+01];
zt = [-1.000000e+03:2.000000e+01:1.000000e+03];
isoval = -1.428280e+01;
h = patch(isosurface(X,Y,Z,V,isoval),... 
'FaceColor', 'blue', ... 
'EdgeColor', 'none', ... 
'AmbientStrength', 0.2, ... 
'SpecularStrength', 0.7, ... 
'DiffuseStrength', 0.4);
isonormals(X,Y,Z,V,h);
patch(isocaps(X,Y,Z,V,isoval), ...
'FaceColor', 'interp', ... 
'EdgeColor', 'none'); 
axis([xlo xhi ylo yhi zlo zhi])
daspect([2.800000e+01,2.000000e+01,2.000000e+03])
set(gca,'linewidth',2)
set(gca,'fontweight','bold')
set(gca,'fontsize',12)
grid on
box on
colormap('default'); colorbar

view(3) 
set(gcf,'Renderer','zbuffer')
lighting phong
cin = 'n';
if (cin == 'y')
xin = questdlg('Axis to slide through ?', 'Axis', 'X', 'Y', 'Z', 'X');
xin = lower(xin);
for i = 1 : 101
if gcf ~= plotFigure
return
end
if (xin == 'y')
h = contourslice(X,Y,Z,V,xt(i),[],[],101);
elseif (xin == 'x')
h = contourslice(X,Y,Z,V,[],yt(i),[],101);
elseif (xin == 'z')
h = contourslice(X,Y,Z,V,[],[],zt(i),101);
end
axis([-1.8000e+01  1.0000e+01  1.0000e+01  3.0000e+01 -1.0000e+03  1.0000e+03 -8.6774e+01  4.2066e+02])
set(gca,'linewidth',2)
set(gca,'fontweight','bold')
set(gca,'fontsize',12)
grid on
box on
view(3)
set(h, 'Linewidth', 10)
colorbar
pause(0.3)
if (i < 101)
clf
end
end
end

解决方案

You may want to have a look at mayavi If you are using Windows, it comes by default with Python(x,y).

这篇关于曲线图matplotlib的彩色立方体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆