Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1124647
  • 博文数量: 221
  • 博客积分: 10152
  • 博客等级: 上将
  • 技术积分: 1518
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-22 10:42
文章分类

全部博文(221)

文章存档

2018年(1)

2015年(6)

2014年(3)

2013年(4)

2012年(1)

2011年(5)

2010年(14)

2009年(10)

2008年(28)

2007年(33)

2006年(114)

2005年(2)

我的朋友

分类: Python/Ruby

2018-12-09 00:12:09

#!/usr/bin/python
#---coding=utf-8
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = Axes3D(fig)
#X Y value
X = np.arange(-4,4,0.25) # X -4 - 4 的 -32个点
Y = np.arange(-4,4,0.25) # Y -4 - 4 的 -32个点
X,Y = np.meshgrid(X,Y)     # 生成32X32网络 ?
R = np.sqrt(X**2 + Y**2)    # 算出32X32 的矩阵 数值为 X**2+Y**2
#hight value    
Z = np.sin(R)                            # 高程数据

#伪3D显示
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.get_cmap('rainbow'))
"""
============= ================================================
        Argument      Description
        ============= ================================================
        *X*, *Y*, *Z* Data values as 2D arrays
        *rstride*     Array row stride (step size), defaults to 10
        *cstride*     Array column stride (step size), defaults to 10
        *color*       Color of the surface patches
        *cmap*        A colormap for the surface patches.
        *facecolors*  Face colors for the individual patches
        *norm*        An instance of Normalize to map values to colors
        *vmin*        Minimum value to map
        *vmax*        Maximum value to map
        *shade*       Whether to shade the facecolors
        ============= ================================================
"""

# I think this is different from plt12_contours
#平面投影
ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=plt.get_cmap('rainbow'))
"""
==========  ================================================
        Argument    Description
        ==========  ================================================
        *X*, *Y*,   Data values as numpy.arrays
        *Z*
        *zdir*      The direction to use: x, y or z (default)
        *offset*    If specified plot a projection of the filled contour
                    on this position in plane normal to zdir
        ==========  ================================================
"""
ax.set_zlim(-2, 2) # Z坐标范围为 -2 -2
plt.show()


"""
坑---- 此文件为网络抄回,运行没问题,但改了下从文件中读取出来的所谓数字其实是string ,必须转换成float :
            f_arr=f_line.replace("\n","").split(":") # 干掉换行符以冒号分割各元组
            arr.append(f_arr[0])                                    # 第一列为字符串,直接append
            t_time=map(float,f_arr[1:])                    # 后面各列需由字符串类型转为浮点数
            arr.extend(t_time)                                # 整理后各列归队
            arr_all.append(arr)                                    # 加入到准备转矩阵的数组中

"""
阅读(1251) | 评论(0) | 转发(0) |
0

上一篇:盏鬼粤语2

下一篇:没有了

给主人留下些什么吧!~~