本文整理汇总了Python中Stoner.Data.text方法的典型用法代码示例。如果您正苦于以下问题:Python Data.text方法的具体用法?Python Data.text怎么用?Python Data.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stoner.Data
的用法示例。
在下文中一共展示了Data.text方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exp
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import text [as 别名]
d.plot(fmt="ro") # plot our data
func = lambda x, A, B, C: A + B * exp(-x / C)
# Do the fitting and plot the result
fit = d.differential_evolution(
func, result=True, header="Fit", A=1, B=1, C=1, prefix="Model", residuals=True
)
# Reset labels
d.labels = []
# Make nice two panel plot layout
ax = d.subplot2grid((3, 1), (2, 0))
d.setas = "x..y"
d.plot(fmt="g+")
d.title = ""
ax = d.subplot2grid((3, 1), (0, 0), rowspan=2)
d.setas = "xyy"
d.plot(fmt=["r.", "b-"])
d.xticklabels = [[]]
d.xlabel = ""
# Annotate plot with fitting parameters
d.annotate_fit(func, prefix="Model", x=0.7, y=0.3, fontdict={"size": "x-small"})
text = r"$y=A+Be^{-x/C}$" + "\n\n"
d.text(7.2, 3.9, text, fontdict={"size": "x-small"})
d.title = u"Differential Evolution Fit"
示例2: linspace
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import text [as 别名]
# Make some data
x = linspace(-10, 10, 101)
y = SF.quadratic(x + normal(size=len(x), scale=0.1), 4, -2, 11) * normal(
size=len(x), scale=0.05, loc=1.0
)
s = y * 0.05
d = Data(x, y, s, setas="xye", column_headers=["X", "Y"])
d.plot(fmt="r.")
d.polyfit(result=True, header="Polyfit")
d.setas = "x..y"
d.plot(fmt="m-", label="Polyfit")
d.text(
-9,
450,
"Polynominal co-efficients\n{}".format(d["2nd-order polyfit coefficients"]),
fontdict={"size": "x-small", "color": "magenta"},
)
d.setas = "xy"
d.curve_fit(SF.quadratic, result=True, header="Curve-fit")
d.setas = "x...y"
d.plot(fmt="b-", label="curve-fit")
d.annotate_fit(
SF.quadratic,
prefix="quadratic",
x=0.2,
y=0.65,
fontdict={"size": "x-small", "color": "blue"},
)
示例3: Data
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import text [as 别名]
"""Example of using lmfit to do a bounded fit."""
from Stoner import Data
from Stoner.Fit import StretchedExp
# Load dat and plot
d = Data("lmfit_data.txt", setas="xy")
# Do the fit
d.lmfit(StretchedExp, result=True, header="Fit", prefix="")
# plot
d.setas = "xyy"
d.plot(fmt=["+", "-"])
# Make apretty label using Stoner.Util methods
text = r"$y=A e^{-\left(\frac{x}{x_0}\right)^\beta}$" + "\n"
text += d.annotate_fit(StretchedExp, text_only=True, prefix="")
d.text(6, 4e4, text)
示例4: linspace
# 需要导入模块: from Stoner import Data [as 别名]
# 或者: from Stoner.Data import text [as 别名]
"""Decompose Example"""
from Stoner import Data
from Stoner.tools import format_val
from numpy import linspace, reshape, array
x = linspace(-10, 10, 201)
y = 0.3 * x ** 3 - 6 * x ** 2 + 11 * x - 20
d = Data(x, y, setas="xy", column_headers=["X", "Y"])
d.decompose()
d.setas = "xyyy"
coeffs = d.polyfit(polynomial_order=3)
str_coeffs = [format_val(c, mode="eng") for c in coeffs.ravel()]
str_coeffs = reshape(array(str_coeffs), coeffs.shape)
d.plot()
d.text(-6, -800, "Coefficients\n{}".format(str_coeffs), fontdict={"size": "x-small"})
d.ylabel = "Data"
d.title = "Decompose Example"
d.tight_layout()