抱歉我的英语不正确。
我修改了代码这里以适应TikZ datavisualization
。以下是改编后的代码:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage[per-mode = fraction]{siunitx}
\usetikzlibrary{datavisualization.formats.functions}
\begin{document}
\begin{tikzpicture}
\datavisualization[
scientific axes = {clean, end labels},
all axes = {ticks and grid = {major at = 0}},
x axis = {label = $\frac{H}{\si{\A\per\m}}$},
y axis = {label = $\frac{B(H)}{\si{\tesla}}$},
data/format = function,
visualize as smooth line/.list = {left, right}
]
data[set = left] {
var x : interval [-7 : 7];
func y = 5 / (1 + exp(-1.7 * \value x - 1.5)) - 2.5;
}
data[set = right] {
var x : interval [-7 : 7];
func y = 5 / (1 + exp(-1.7 * \value x + 1.5)) - 2.5;
}
%accents important points
info {
\draw (visualization cs:x = {(-1.5 / 1.7)}, y = 0) circle [radius = 1pt]
node [left, font = \footnotesize] {$H_C$};
}
info {
\draw (visualization cs:x = 0, y = 1.59) circle [radius = 1pt]
node [left, font=\footnotesize] {$B_R$};
}
info {
\draw (visualization cs:x = 7, y = 2.5) circle [radius = 1pt]
node [above, font=\footnotesize] {$B_S$};
};
\end{tikzpicture}
\end{document}
但我遇到了许多这样的错误:
!尺寸太大
\pgfmath@iterate
。...\pgfmath@xa \ifdim \pgfmath@x
你也可以使用TikZ fpu
类似这里,这里和这里。这是我的代码:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage[per-mode = fraction]{siunitx}
\usetikzlibrary{datavisualization.formats.functions,fpu}
\begin{document}
\begin{tikzpicture}
\datavisualization[
scientific axes = {clean, end labels},
all axes = {ticks and grid = {major at = 0}},
x axis = {label = $\frac{H}{\si{\A\per\m}}$},
y axis = {label = $\frac{B(H)}{\si{\tesla}}$},
data/format = function,
visualize as smooth line/.list = {left, right}
]
data[set = left] {
var x : interval [-7 : 7];
\pgfkey{/pgf/fpu, /pgf/fpu/output format=fixed}
func y = 5 / (1 + exp(-1.7 * \value x - 1.5)) - 2.5;
\pgfkeys{/pgf/fpu=false}
}
data[set = right] {
var x : interval [-7 : 7];
\pgfkey{/pgf/fpu, /pgf/fpu/output format=fixed}
func y = 5 / (1 + exp(-1.7 * \value x + 1.5)) - 2.5;
\pgfkeys{/pgf/fpu=false}
}
%accents important points
info {
\draw (visualization cs:x = {(-1.5 / 1.7)}, y = 0) circle [radius = 1pt]
node [left, font = \footnotesize] {$H_C$};
}
info {
\draw (visualization cs:x = 0, y = 1.59) circle [radius = 1pt]
node [left, font=\footnotesize] {$B_R$};
}
info {
\draw (visualization cs:x = 7, y = 2.5) circle [radius = 1pt]
node [above, font=\footnotesize] {$B_S$};
};
\end{tikzpicture}
\end{document}
但是我的pdfLaTeX
编译器TeXnicCenter
陷入了无限循环。我哪里做错了?
顺便说一句:上面的装饰线看起来已经一样了(只有坐标、对齐和文本变化)。有没有办法合并/优化它。
提前谢谢你的帮助!
答案1
似乎当 x 值变成“大”负数时,它就会崩溃。如果将曲线的下限更改left
为 -6.5,并将right
曲线更改为 -4.5,则在此处编译正常。
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage[per-mode = fraction]{siunitx}
\usetikzlibrary{datavisualization.formats.functions}
\begin{document}
\begin{tikzpicture}
\datavisualization[
scientific axes = {clean, end labels},
all axes = {ticks and grid = {major at = 0}},
x axis = {label = $\frac{H}{\si{\A\per\m}}$},
y axis = {label = $\frac{B(H)}{\si{\tesla}}$},
data/format = function,
visualize as smooth line/.list = {left, right}
]
data[set = left] {
var x : interval [-6.5 : 7];
func y = 5 / (1 + exp(-1.7 * \value x - 1.5)) - 2.5;
}
data[set = right] {
var x : interval [-4.5 : 7];
func y = 5 / (1 + exp(-1.7 * \value x + 1.5)) - 2.5;
}
%accents important points
info {
\draw (visualization cs:x = {(-1.5 / 1.7)}, y = 0) circle [radius = 1pt]
node [left, font = \footnotesize] {$H_C$};
}
info {
\draw (visualization cs:x = 0, y = 1.59) circle [radius = 1pt]
node [left, font=\footnotesize] {$B_R$};
}
info {
\draw (visualization cs:x = 7, y = 2.5) circle [radius = 1pt]
node [above, font=\footnotesize] {$B_S$};
};
\end{tikzpicture}
\end{document}