def plot(self,title="",label=""):
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
if self.distance == None:
zlabel = "Flux (phot/s/0.1%bw/mrad2)"
xlabel = 'X [rad]'
ylabel = 'Y [rad]'
else:
zlabel = "Flux (phot/s/0.1%bw/mm2)"
xlabel = 'X [m]'
ylabel = 'Y [m]'
if self.X is None or self.Y is None:
raise Exception(" X and Y must be array for plotting")
if self.X.shape != self.Y.shape:
raise Exception(" X and Y must have the same shape")
fig = plt.figure()
if len(self.X.shape) ==2 :
ax = Axes3D(fig)
ax.plot_surface(self.X, self.Y, self.intensity, rstride=1, cstride=1,cmap='hot_r')
else :
ax = fig.gca(projection='3d')
ax.plot(self.X, self.Y, self.intensity, label=label)
ax.legend()
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
ax.set_zlabel(zlabel)
plt.title(title)
plt.show()
评论列表
文章目录