本文整理汇总了Python中Stoner.Data.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Data.draw方法的具体用法?Python Data.draw怎么用?Python Data.draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stoner.Data
的用法示例。
在下文中一共展示了Data.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import draw [as 别名]
d.show()
#Now convert the angle to sin^2
t.apply(lambda x: np.sin(np.radians(x[0]/2.0))**2, 0,header=r"$sin^2\theta$")
# Now create the m^2 order
m=np.arange(len(t))+fringe_offset
m=m**2
#And add it to t
t.add_column(m, column_header='$m^2$')
#Now we can it a straight line
t.setas="x..y"
fit=t.lmfit(Linear,result=True,replace=False,header="Fit")
g=t["LinearModel:slope"]
gerr=t["LinearModel:slope err"]/g
g=np.sqrt(1.0/g)
gerr/=2.0
l=float(d['Lambda'])
th=l/(2*g)
therr=th*(gerr)
t.inset(loc="top right",width=0.5,height=0.4)
t.plot_xy(r"Fit",r"$sin^2\theta$", 'b-',label="Fit")
t.plot_xy(r"$m^2$",r"$sin^2\theta$", 'ro',label="Peak Position")
t.xlabel="Fringe $m^2$"
t.ylabel=r"$sin^2\theta$"
t.title=""
t.legend(loc="upper left")
t.draw()
pyplot.sca(t.axes[0])
# Get the wavelength from the metadata
# Calculate thickness and report
pyplot.text (0.05,0.05, "Thickness is: {} $\AA$".format(format_error(th,therr,latex=True)), transform=main_fig.axes[0].transAxes)
示例2: plane
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import draw [as 别名]
def plane(coord, a, b, c):
"""Function to define a plane"""
return c - (coord[0] * a + coord[1] * b)
coeefs = [1, -0.5, -1]
col = linspace(-10, 10, 6)
X, Y = meshgrid(col, col)
Z = plane((X, Y), *coeefs) + normal(size=X.shape, scale=7.0)
d = Data(
column_stack((X.ravel(), Y.ravel(), Z.ravel())),
filename="Fitting a Plane",
setas="xyz",
)
d.column_headers = ["X", "Y", "Z"]
d.figure(projection="3d")
d.plot_xyz(plotter="scatter")
popt, pcov = d.curve_fit(plane, [0, 1], 2, result=True)
d.setas = "xy.z"
d.plot_xyz(linewidth=0, cmap=cmap.jet)
txt = "$z=c-ax+by$\n"
txt += "\n".join([d.format("plane:{}".format(k), latex=True) for k in ["a", "b", "c"]])
ax = plt.gca(projection="3d")
ax.text(15, 5, -50, txt)
d.draw()