本文整理汇总了Python中mpl_toolkits.mplot3d.Axes3D.plot_surface方法的典型用法代码示例。如果您正苦于以下问题:Python Axes3D.plot_surface方法的具体用法?Python Axes3D.plot_surface怎么用?Python Axes3D.plot_surface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.mplot3d.Axes3D
的用法示例。
在下文中一共展示了Axes3D.plot_surface方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot_surface [as 别名]
def draw(self, axes: Axes3D):
R = (self.orientation * (self.orientation_origin.get_inverse())).to_rot_matrix()
xx = R[0, 0] * self.x + R[0, 1] * self.y + R[0, 2] * self.z
yy = R[1, 0] * self.x + R[1, 1] * self.y + R[1, 2] * self.z
zz = R[2, 0] * self.x + R[2, 1] * self.y + R[2, 2] * self.z
axes.plot_surface(xx, yy, zz, rstride=4, cstride=4, color='b')
return axes,
示例2: water
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot_surface [as 别名]
def water(self, *argv): # Dimension is unit type as V(olt) W(att), etc
# http://matplotlib.org/examples/mplot3d/polys3d_demo.html
Axes3D.plot_surface(self.signalx, self.signaly, self.signalz) # till better funcion
plt.xlabel('time [s]') # Or Sample number
plt.ylabel('Frequency [Hz]') # Or Freq Bins number
plt.zlabel('voltage [mV]') # auto add unit here
plt.title(' ') # set title
plt.grid(True)
plt.show()
示例3: Spect
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot_surface [as 别名]
def Spect(self): #, dimension): # Dimension is unit type as V(olt) W(att), etc
Axes3D.plot_surface(self.signalx, self.signaly, self.signalz)
if self.signalx.shape == self.signaly.shape == self.signalz.shape:
pass
elif self.signalx.shape == (len(self.signalx), ) or self.signaly.shape == (len(self.signaly), ):
# Check for 1D array both
if self.signalx.shape == (len(self.signalx), ) and self.signaly.shape == (len(self.signaly), ):
self.signalx, self.signaly = np.meshgrid(self.signalx, self.signaly)
nx, mx = np.shape(self.signalx)
nz, mz = np.shape(self.signalz)
if nx == nz and mx == mz:
pass
elif nx == mz and mx == nz:
self.signalz = np.rot90(self.signalz, 1)
# find out if it has to be 1 or 3
elif self.signalx.shape == (len(self.signalx), ):
pass
elif self.signaly.shape == (len(self.signaly), ):
pass
if self.signalx.shape == self.signaly.shape != self.signalz.shape:
nx, mx = np.shape(self.signalx)
nz, mz = np.shape(self.signalz)
if nx == nz and mx == mz:
pass
elif nx == mz and mx == nz:
self.signalz = np.rot90(self.signalz, 1)
# find out if it has to be 1 or 3
elif self.signalx.shape == self.signalz.shape != self.signaly.shape:
nx, mx = np.shape(self.signalx)
ny, my = np.shape(self.signalz)
if nx == ny and mx == my:
pass
elif nx == my and mx == ny:
self.signaly = np.rot90(self.signaly, 1)
# find out if it has to be 1 or 3
elif self.signaly.shape == self.signalz.shape != self.signalx.shape:
ny, my = np.shape(self.signaly)
nx, mx = np.shape(self.signalx)
if ny == nx and my == mx:
pass
elif ny == mx and my == nx:
self.signalz = np.rot90(self.signalz, 1)
# find out if it has to be 1 or 3
else:
raise MeasError.DataError("No Valid data found in at least one of the axis")
plt.xlabel('time [s]') # Or Sample number
plt.ylabel('Frequency [Hz]') # Or Freq Bins number
plt.zlabel('voltage [mV]') # auto add unit here
plt.title(' ') # set title
plt.grid(True)
plt.show()
示例4: updatePlot
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot_surface [as 别名]
def updatePlot(self, X, Y, Z, population=None):
self.activePlot = (X,Y,Z)
x, y = np.meshgrid(X,Y)
if self.surface is not None:
self.surface.remove()
if self.scatter is not None:
self.scatter.remove()
# surface
self.surface = Axes3D.plot_surface(
self.axes,
x, y, Z,
rstride=1,
cstride=1,
cmap=cm.coolwarm,
linewidth=0,
antialiased=False,
shade=False,
alpha=0.5
)
# population
if population is not None:
self.activePopulation = population
x, y, z = self.preparePopulationData(population)
self.scatter = Axes3D.scatter(self.axes, x, y, z, c="r", marker="o")
self.scatter.set_alpha(1.0)
# Draw all
self.canvas.draw()
self.canvas.flush_events()
示例5: range
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot_surface [as 别名]
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 22 20:56:55 2015
@author: jderoo
"""
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#D is a vector from 0 to 3, 100 spaces in between
D = np.linspace(0,3,100)
#U is a vector from 0 to 3, 100 spaces in between
U = np.linspace(0,3,100)
#A is a blank matrix/list
A = []
#for loop that ranges i from 0 to 100 steps of 1
for i in range(0,100,1):
#for loop that ranges j from 0 to 100 steps of 1
for j in range(0,100,1):
#The base equation we were given in the homework
r = ((3*D[i]*(U[j])^.7)/(1 + D[i]^.95 + U[j])^.3)
#in cell location i,j place the calced value of r
A[i,j] = r
#3D plot D, U, and the now filled matrix A
Axes3D.plot_surface(D,U,A)
示例6: saveoutput
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot_surface [as 别名]
#.........这里部分代码省略.........
# -------------------------------------------------
if (Nd_step>=1 and Ng_step==0):
figure(1)
plot(Vd_bias, Ie[0,:], 'o-')
grid(True)
xlabel('$V_{DS}$ [V]')
ylabel('$I_{DS} [\mu A/\mu m]$')
title('$I_{DS}$ vs. $V_{DS}$')
savefig('ID_VD.png')
#temmm = [Vd_bias, Ie[0,:]]
#np.savetxt('ID_VD.dat', temmm, fmt='%e', delimiter=';')
temmm = Vd_bias
Ie2 = Ie.transpose()
fid = open('ID_{VD}.dat','w')
ind = 0
for item1 in temmm:
fid.write("%e " % item1)
for item2 in Ie2[ind,:]:
fid.write("%e " % item2)
fid.write('\n')
ind += 1
fid.close()
#if plot_Iv==1 end
#***************************************************************************************
# Ec(X,Y)
# -------------------------------------------
if plot_Ec3d == 1:
figure(6)
[X, Y] = np.meshgrid(XI, YI)
Z = trMEc
ax = gca(projection = '3d')
surf = ax.plot_surface(X, Y, Z, rstride=3, cstride=3, cmap=cm.coolwarm, linewidth=0.5, antialiased = True)
#surf(XI,YI,trMEc)
#shading interp commented out to reduce size of the .ps file
title('3D Conduction band edge potential profile')
ax.set_xlabel('X [nm]')
ax.set_ylabel('Y [nm]')
ax.set_zlabel('Ec [eV]')
ax.view_init(elev=60, azim=50)
ax.dist=8
savefig('Ec_X_Y.png')
XII = (0, XI)
tem1 = (YI, trMEc)
tem2 = (XII, tem1)
#np.savetxt('Ec_X_Y.dat', tem2, fmt='%e', delimiter=';')
#f1 = open('Ec_X_Y','w')
#writer = csv.writer(f1, delimiter = ',')
#writer.writerows(tem2)
#*******************************************************************************************
if (plot_Ecsub==1 and max_subband>=1):
figure(8)
for iii in np.arange(0,max_subband):
plot(XI, E_sub[0, Ng_step, Nd_step, :, iii],'r-')
hold(True)
grid(True)
if (t_vall==3):
plot(XI, E_sub[1, Ng_step, Nd_step, :,iii],'k-')
plot(XI, E_sub[2, Ng_step, Nd_step, :,iii],'-')
示例7: print
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot_surface [as 别名]
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 27 20:10:40 2016
@author: Bhuti
"""
import pandas as pd
pd.set_option('display.max_row', 1000)
pd.set_option('display.max_columns', 50)
got = pd.read_csv ('/Users/Bhuti/Desktop/war_of_the_five_kings_dataset-master/5kings_battles_v1.csv')
got = pd.DataFrame(got)
# print(got['attacker_size'])
print(got['defender_king'].value_counts())
got['defender_king'].value_counts().plot(kind='bar')
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = got['year']
y = got['battle_number']
z = got['attacker_size']
# Axes3D.plot_surface('defender_1','battle_number','attacker_outcome')
Axes3D.plot_surface(x,y,z)
示例8: range
# 需要导入模块: from mpl_toolkits.mplot3d import Axes3D [as 别名]
# 或者: from mpl_toolkits.mplot3d.Axes3D import plot_surface [as 别名]
theta0_vals = np.linspace(-10, 10, 100)
theta1_vals = np.linspace(-1, 4, 100)
# initialize J_vals to a matrix of 0's
J_vals = np.zeros((len(theta0_vals),len(theta1_vals)))
# Fill out J_Vals
# Note: There is probably a more efficient way to do this that uses
# broadcasting instead of the nested for loops
for i in range(len(theta0_vals)):
for j in range(len(theta1_vals)):
t = np.array([theta0_vals[i],theta1_vals[j]])
J_vals[i][j] = computeCost(X,y,t)
# Surface plot using J_Vals
fig = plt.figure()
ax = plt.subplot(111,projection='3d')
Axes3D.plot_surface(ax,theta0_vals,theta1_vals,J_vals,cmap=cm.coolwarm)
plt.show()
# Contour plot
# TO DO: Currently does not work as expected. Need to find a way to mimic
# the logspace option in matlab
fig = plt.figure()
ax = plt.subplot(111)
plt.contour(theta0_vals,theta1_vals,J_vals)
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4