当前位置: 首页>>代码示例>>Python>>正文


Python Data.plot_xyz方法代码示例

本文整理汇总了Python中Stoner.Data.plot_xyz方法的典型用法代码示例。如果您正苦于以下问题:Python Data.plot_xyz方法的具体用法?Python Data.plot_xyz怎么用?Python Data.plot_xyz使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stoner.Data的用法示例。


在下文中一共展示了Data.plot_xyz方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: uniform

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import plot_xyz [as 别名]
# Create some points approximately spherical distribution
p = uniform(low=-pi / 2, high=pi / 2, size=250)
q = uniform(low=-pi, high=pi, size=250)
r = normal(loc=3.0, size=250, scale=0.5)

x, y, z = transform(r, q, p)

x += 3.0
y -= 4.0
z += 2.0

# Construct the  DataFile object
d = Data(column_stack((x, y, z)), setas="xyz", filename="Best fit sphere")
d.template.fig_width = 5.2
d.template.fig_height = 5.0  # Square aspect ratio
d.plot_xyz(plotter="scatter")

# curve_fit does the hard work
popt, pcov = d.curve_fit(sphere, (0, 1, 2), zeros_like(d.x))

# This manually constructs the best fit sphere
a, b, c, r = popt
p = linspace(-pi / 2, pi / 2, 16)
q = linspace(-pi, pi, 31)
P, Q = meshgrid(p, q)
R = ones_like(P) * r
x, y, z = transform(R, Q, P)
x += a
y += b
z += c
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:32,代码来源:sphere_fit.py

示例2: plane

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import plot_xyz [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()
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:32,代码来源:curve_fit_plane.py

示例3: Data

# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import plot_xyz [as 别名]
"""3D surface plot example."""
from Stoner import Data
import numpy as np
import matplotlib.cm

x, y = np.meshgrid(np.linspace(-2, 2, 100), np.linspace(-2, 2, 100))
x = x.ravel()
y = y.ravel()
z = np.cos(4 * np.pi * np.sqrt(x ** 2 + y ** 2)) * np.exp(-np.sqrt(x ** 2 + y ** 2))

p = Data()
p = p & x & y & z
p.column_headers = ["X", "Y", "Z"]
p.setas = "xyz"

p.plot_xyz(cmap=matplotlib.cm.jet)
p.title = "Surface plot"
开发者ID:gb119,项目名称:Stoner-PythonCode,代码行数:19,代码来源:3D_plot.py


注:本文中的Stoner.Data.plot_xyz方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。