是否有任何用于绘制矢量场的 PSTricks 包?
我已经看过了http://tug.org/PSTricks/main.cgi?file=examples#vector但我并不完全理解示例中的语法。我还查看了第 23 页http://users.math.msu.edu/users/hensh/latex/pstricks/seminarSS08.pdf但这里缺少代码。:(
具体来说,我想绘制矢量场
{1, x}
在两个轴上的范围都是从 -5 到 5。这是使用 Mathematica 绘制的矢量场:
更新
我已经想出了如何去做(或多或少):
\documentclass{article}
\usepackage{
pst-plot,
pst-ode
}
\psset{
unit=5,
algebraic,
algebraicOutputFormat
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{pspicture}(-1.1,-1.1)(1.1,1.1)
\psaxes[
dx=0.2,
Dx=1,
dy=0.2,
Dy=1
]{->}(0,0)(-1.1,-1.1)(1.1,1.1)
\psVectorfield[
arrows=->,
linecolor=black!60
](-1,-1)(1,1){x}
\pstODEsolve{y0_a}{t | x[0]}{-1}{1}{100}{-0.1}{t}
\pstODEsolve{y0_b}{t | x[0]}{-1}{1}{100}{0.1}{t}
\pstODEsolve{y0_c}{t | x[0]}{-1}{1}{100}{0.3}{t}
\pstODEsolve{y0_d}{t | x[0]}{-1}{1}{100}{0.5}{t}
\pstODEsolve{y0_e}{t | x[0]}{-1}{1}{100}{0.7}{t}
\pstODEsolve{y0_f}{t | x[0]}{-1}{1}{100}{0.9}{t}
\psset{
arrows=-,
linewidth=1.5pt
}
\listplot[linecolor=gray ]{y0_a}
\listplot[linecolor=red ]{y0_b}
\listplot[linecolor=green ]{y0_c}
\listplot[linecolor=blue ]{y0_d}
\listplot[linecolor=purple]{y0_e}
\listplot[linecolor=yellow]{y0_f}
\end{pspicture}
\caption{Vektorfeltet~$\mathbf{F}(x,y) = (1,x)$ med nogle str{\o}mningskurver.}
\end{figure}
\end{document}
问题是,图片实际上只是在两个轴上从 -1 到 1 绘制的(但我更改了轴标签)。这意味着,与在两个轴上从 -5 到 5 绘制相比,矢量箭头和曲线太“平坦”了。
我尝试将代码改为
\documentclass{article}
\usepackage{
pst-plot,
pst-ode
}
\psset{
unit=1,
algebraic,
algebraicOutputFormat
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{pspicture}(-5.7,-5.7)(5.7,5.7)
\psaxes[
dx=1,
Dx=1,
dy=1,
Dy=1
]{->}(0,0)(-5.5,-5.5)(5.5,5.5)
\psVectorfield[
arrows=->,
linecolor=black!60
](-5,-5)(5,5){x}
\pstODEsolve{y0_a}{t | x[0]}{-5}{5}{100}{-0.5}{t}
\pstODEsolve{y0_b}{t | x[0]}{-5}{5}{100}{0.5}{t}
\pstODEsolve{y0_c}{t | x[0]}{-5}{5}{100}{1.5}{t}
\pstODEsolve{y0_d}{t | x[0]}{-5}{5}{100}{2.5}{t}
\pstODEsolve{y0_e}{t | x[0]}{-5}{5}{100}{3.5}{t}
\pstODEsolve{y0_f}{t | x[0]}{-5}{5}{100}{4.5}{t}
\psset{
arrows=-,
linewidth=1.5pt
}
\listplot[linecolor=gray ]{y0_a}
\listplot[linecolor=red ]{y0_b}
\listplot[linecolor=green ]{y0_c}
\listplot[linecolor=blue ]{y0_d}
\listplot[linecolor=purple]{y0_e}
\listplot[linecolor=yellow]{y0_f}
\end{pspicture}
\caption{Vektorfeltet~$\mathbf{F}(x,y) = (1,x)$ med nogle str{\o}mningskurver.}
\end{figure}
\end{document}
但后来我得到了错误
Runaway definition?
->/ArrowA { moveto } def /ArrowB { BeginArrow 1. 1. scale false 0.\ETC.
! TeX capacity exceeded, sorry [main memory size=5000000].
\pst@code ....setopacityalpha Arrow EndArrow }
def
l.28 ](-5,-5)(5,5){x}
我该如何解决?
更新 2
以下是我最终得到的结果:
\documentclass{article}
\usepackage{pst-plot}
\usepackage{pst-ode}
\begin{document}
\begin{figure}[htbp]
\centering
\psset{
algebraic,
algebraicOutputFormat
}
\begin{pspicture}(-5.47,-5.47)(5.85,5.9)
\psaxes[
linecolor=lightgray
]{->}(0,0)(-5.5,-5.5)(5.5,5.5)[$x$,0][$y$,90]
\psVectorfield[
Ox=10,
Dx=1,
Dy=1,
linecolor=blue
](-5,-5)(5,5){x}
\pstODEsolve{y0_a}{t | x[0]}{-2.1}{2.1}{100}{5.205}{t}
\pstODEsolve{y0_b}{t | x[0]}{-2.533}{2.533}{100}{5.208}{t}
\pstODEsolve{y0_c}{t | x[0]}{-2.9}{2.9}{100}{5.205}{t}
\pstODEsolve{y0_d}{t | x[0]}{-3.226}{3.226}{100}{5.2025}{t}
\pstODEsolve{y0_e}{t | x[0]}{-3.523}{3.523}{100}{5.2055}{t}
\pstODEsolve{y0_f}{t | x[0]}{-3.797}{3.797}{100}{5.208}{t}
\pstODEsolve{y0_g}{t | x[0]}{-4.051}{4.051}{100}{5.205}{t}
\psset{
linewidth=1.5pt
}
\listplot[linecolor=red!20]{y0_a}
\listplot[linecolor=red!30]{y0_b}
\listplot[linecolor=red!40]{y0_c}
\listplot[linecolor=red!50]{y0_d}
\listplot[linecolor=red!60]{y0_e}
\listplot[linecolor=red!70]{y0_f}
\listplot[linecolor=red!80]{y0_g}
% \listplot[linecolor=purple]{y0_a}
% \listplot[linecolor=green ]{y0_b}
% \listplot[linecolor=red ]{y0_c}
% \listplot[linecolor=blue ]{y0_d}
% \listplot[linecolor=orange]{y0_e}
% \listplot[linecolor=gray ]{y0_f}
% \listplot[linecolor=yellow]{y0_g}
\end{pspicture}
\end{figure}
\end{document}
更新 3
当我使用 AlexG 在评论中提到的程序时回答ps
由 Marienplatz 提供,从到进行编译时pdf
(即调用 时)仍然会收到错误ps2pdf
(但 PDF 文件看起来正常):
\documentclass{article}
\usepackage{pst-plot}
\usepackage{pst-ode}
\begin{document}
\begin{figure}[htbp]
\centering
\psset{
algebraic,
algebraicOutputFormat
}
\begin{pspicture}(-5.47,-5.47)(5.85,5.9)
\psVectorfield[
Ox=10,
Dx=1,
Dy=1,
linecolor=blue
](-5,-5)(5,5){x}
\pstODEsolve{y0_a}{t | x[0]}{-2.1}{2.1}{100}{5.205}{t}
\pstODEsolve{y0_b}{t | x[0]}{-2.533}{2.533}{100}{5.208}{t}
\pstODEsolve{y0_c}{t | x[0]}{-2.9}{2.9}{100}{5.205}{t}
\pstODEsolve{y0_d}{t | x[0]}{-3.226}{3.226}{100}{5.2025}{t}
\pstODEsolve{y0_e}{t | x[0]}{-3.523}{3.523}{100}{5.2055}{t}
\pstODEsolve{y0_f}{t | x[0]}{-3.797}{3.797}{100}{5.208}{t}
\pstODEsolve{y0_g}{t | x[0]}{-4.051}{4.051}{100}{5.205}{t}
\psaxes[
linecolor=lightgray
]{->}(0,0)(-5.5,-5.5)(5.5,5.5)[$x$,0][$y$,90]
\psset{
linewidth=1.5pt
}
\listplot[linecolor=red!20]{y0_a}
\listplot[linecolor=red!30]{y0_b}
\listplot[linecolor=red!40]{y0_c}
\listplot[linecolor=red!50]{y0_d}
\listplot[linecolor=red!60]{y0_e}
\listplot[linecolor=red!70]{y0_f}
\listplot[linecolor=red!80]{y0_g}
% \listplot[linecolor=purple]{y0_a}
% \listplot[linecolor=green ]{y0_b}
% \listplot[linecolor=red ]{y0_c}
% \listplot[linecolor=blue ]{y0_d}
% \listplot[linecolor=orange]{y0_e}
% \listplot[linecolor=gray ]{y0_f}
% \listplot[linecolor=yellow]{y0_g}
\end{pspicture}
\end{figure}
\end{document}
错误如下:
pstODEsolve RKF45 method; '-' failed step, '+' successful step, 'o' output step :
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
pstODEsolve RKF45 method; '-' failed step, '+' successful step, 'o' output step :
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
pstODEsolve RKF45 method; '-' failed step, '+' successful step, 'o' output step :
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
pstODEsolve RKF45 method; '-' failed step, '+' successful step, 'o' output step :
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
pstODEsolve RKF45 method; '-' failed step, '+' successful step, 'o' output step :
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
pstODEsolve RKF45 method; '-' failed step, '+' successful step, 'o' output step :
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
pstODEsolve RKF45 method; '-' failed step, '+' successful step, 'o' output step :
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooError: /invalidrestore in --restore--
Operand stack:
(1) 1786 1388 5.0 (2) 1786 1152 5.0 (3) 1786 916 5.0 (4) 1786 679 5.0 (5) 1721 2093 5.0 (1) 1721 2329 5.0 (2) 1721 2566 5.0 (3) 1721 2802 5.0 (4) 1721 3038 5.0 (5) 2117 1962 5.0 (5) 1902 1834 5.0 (x) 1902 1834 5.0 (y) 1902 1834 5.0 --nostringval-- --nostringval--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1884 1 3 %oparray_pop 1883 1 3 %oparray_pop 1867 1 3 %oparray_pop 1755 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- 1807 53 4 %oparray_pop --nostringval-- 1791 53 4 %oparray_pop --nostringval--
Dictionary stack:
--dict:1171/1684(ro)(G)-- --dict:8/20(G)-- --dict:117/200(L)-- --dict:187/300(L)--
Current allocation mode is local
Last OS error: Numerical result out of range
Current file position is 259609
GPL Ghostscript 9.10: Unrecoverable error, exit code 1
答案1
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\usepackage{pst-ode}
\psset{algebraic,algebraicOutputFormat}
\begin{document}
\begin{pspicture}(-5.7,-14.7)(5.7,5.7)
\psaxes[linecolor=lightgray]{->}(0,0)(-5.5,-14.5)(5.5,5.5)[$x$,0][$y$,90]
\psVectorfield[Dx=1,Dy=1,Ox=10](-5,-14.5)(5,5){x}
\pstODEsolve{y0_a}{t | x[0]}{-5}{5}{100}{-0.5}{t}
\pstODEsolve{y0_b}{t | x[0]}{-5}{5}{100}{0.5}{t}
\pstODEsolve{y0_c}{t | x[0]}{-5}{5}{100}{1.5}{t}
\pstODEsolve{y0_d}{t | x[0]}{-5}{5}{100}{2.5}{t}
\pstODEsolve{y0_e}{t | x[0]}{-5}{5}{100}{3.5}{t}
\pstODEsolve{y0_f}{t | x[0]}{-5}{5}{100}{4.5}{t}
\psset{linewidth=1.5pt}
\listplot[linecolor=gray ]{y0_a}
\listplot[linecolor=red ]{y0_b}
\listplot[linecolor=green ]{y0_c}
\listplot[linecolor=blue ]{y0_d}
\listplot[linecolor=purple]{y0_e}
\listplot[linecolor=yellow]{y0_f}
\end{pspicture}
\end{document}
我的编译步骤
echo off
rem %1 TeX input filename without extension
latex "%~1.tex"
dvips -t unknown "%~1.dvi"
rem I invoke ghostscript directly rather than via ps2pdf
gswin64c -dCompatibilityLevel=1.5 -dAutoRotatePages=/None -sDEVICE=pdfwrite -o "%~1.pdf" "%~1.ps"