![使用 PSTricks 绘制图形和数据:错误缩放](https://linux22.com/image/281684/%E4%BD%BF%E7%94%A8%20PSTricks%20%E7%BB%98%E5%88%B6%E5%9B%BE%E5%BD%A2%E5%92%8C%E6%95%B0%E6%8D%AE%EF%BC%9A%E9%94%99%E8%AF%AF%E7%BC%A9%E6%94%BE.png)
考虑以下代码:
\documentclass{article}
\usepackage{pst-plot}
\begin{document}
% options
\psset{
xunit = 5,
yunit = 50
}
% constants.
\def\masse{0.183276667} % kg
\def\kraft{0.0278661} % N
\def\bKonst{0.012} % kg/s
\def\omegaKonst{12.1278} % s^(-1)
% function
\def\amplitude(#1){\kraft/(\omegaKonst*\masse*sqrt(\omegaKonst^2*(#1)^4+(\bKonst^2/\masse^2-2*\omegaKonst^2)*(#1)^2+\omegaKonst^2))}
% data
\readdata{\resonans}{data-resonans.txt}
% plot
\begin{pspicture}(-0.21,-0.011)(1.83,0.191)
\psaxes[
dx = 0.2,
Dx = 0.2,
dy = 0.02,
Dy = 0.005,
comma
]{->}(0,0)(1.5,0.09)[$\omega_{\textup{SHB}}/\omega_{\textup{d}}$,0][$A$~(m),90]
\listplot[
plotstyle = dots,
dotstyle = o,
fillcolor = red
]{\resonans}
\psplot[
algebraic,
plotpoints = 1000,
linecolor = blue
]{0}{1.5}{\amplitude(x)}
\end{pspicture}
\end{document}
如何获得与以下相同的输出?
数据可从以下网址下载http://gupl.dk/705814/。
答案1
\documentclass{article}
\usepackage{pst-plot}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
[[0.6005832177,0.00371],[0.6618893637,0.00388],[0.7123448644,0.00246],[0.7324185582,0.00266],[0.7861292525,0.00328],[0.8523181889,0.00451],[0.9109116735,0.00647],[0.9282727060,0.00760],[0.9906639165,0.0114],[1.025928514,0.0152],[1.051970063,0.0222],[1.079096676,0.0131],[1.105138225,0.00865],[1.149625870,0.00549],[1.170242096,0.00455],[1.220155065,0.00336],[1.256504727,0.00267],[1.351990405,0.00184]]
\end{filecontents*}
\begin{document}
% options
\psset{
xunit = 5,
yunit = 200
}
% constants.
\def\masse{0.183276667} % kg
\def\kraft{0.0278661} % N
\def\bKonst{0.13831} % kg/s
\def\omegaKonst{12.1278} % s^(-1)
% function
\def\amplitude{\kraft/(\omegaKonst*\masse)/%
sqrt(\omegaKonst^2*x^4+(\bKonst^2/\masse^2-2*\omegaKonst^2)*x^2+\omegaKonst^2)}
% data
% plot
\begin{pspicture}(-0.21,-0.011)(1.83,0.021)
\psaxes[
Dx = 0.4,
Dy = 0.005,
comma
]{->}(0,0)(1.5,0.02)[$\omega_{\textup{SHB}}/\omega_{\textup{d}}$,0][$A$~(m),90]
\readdata{\resonans}{data.dat}
\listplot[
plotstyle = dots,
dotstyle = o,
fillcolor = red
]{\resonans}
\psplot[
algebraic,
plotpoints = 5000,
linecolor = blue,
yMaxValue=0.08
]{0}{1.5}{\amplitude}
\end{pspicture}
\end{document}
下面是带有值的解决方案:
\documentclass{article}
\usepackage{pst-plot}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
[[0.6005832177,0.00371],[0.6618893637,0.00388],[0.7123448644,0.00246],[0.7324185582,0.00266],[0.7861292525,0.00328],[0.8523181889,0.00451],[0.9109116735,0.00647],[0.9282727060,0.00760],[0.9906639165,0.0114],[1.025928514,0.0152],[1.051970063,0.0222],[1.079096676,0.0131],[1.105138225,0.00865],[1.149625870,0.00549],[1.170242096,0.00455],[1.220155065,0.00336],[1.256504727,0.00267],[1.351990405,0.00184]]
\end{filecontents*}
\begin{document}
% options
\psset{
xunit = 5,
yunit = 200
}
% function
\def\amplitude{0.0125368/sqrt(147.084-293.598*x^2+147.084*x^4)}
% data
% plot
\begin{pspicture}(-0.21,-0.011)(1.83,0.03)
\psaxes[
Dx = 0.4,
Dy = 0.005,
dy=0.01,
comma
]{->}(0,0)(1.5,0.03)[$\omega_{\textup{SHB}}/\omega_{\textup{d}}$,0][$A$~(m),90]
\readdata{\resonans}{data.dat}
\listplot[
plotstyle = dots,
dotstyle = o,
fillcolor = red
]{\resonans}
\psplot[
algebraic,
plotpoints = 5000,
linecolor = blue,
]{0}{1.5}{\amplitude}
\end{pspicture}
\end{document}