请考虑以下示例:
\documentclass{article}
\usepackage{pst-plot}
\begin{document}
\psset{xunit=0.1,yunit=0.002}
\savedata{\data}[{1924,300},{1928,510},{1932,310},{1936,880},{1948,700},
{1952,730},{1956,820},{1960,660},{1964,1100},{1968,1160},
{1972,1220},{1976,1130},{1980,1070},{1984,1300},{1988,1430},
{1992,1810},{1994,1750},{1998,2176},{2002,2399}]
\begin{pspicture}(-9,-240)(102,2950)
\psaxes[
dx=10,
dy=500,
labels=none,
ticklinestyle=dotted,
tickwidth=0.5pt,
xticksize=0 2500,
yticksize=0 90
]{->}(0,0)(0,0)(95,2750)[Year,0][Participants,90]
\psaxes[
Ox=1920,
Dx=10,
Dy=500
](0,0)(0,0)(95,2750)
% Data (NOT working)
\dataplot[
plotstyle=dots,
dotstyle=o,
fillcolor=red
]{\data}
% Years 1924--1976
\psplot[
linecolor=blue,
algebraic
]{4}{56}{15.6394*x+303.3}% Regression with Mathematica
% Years 1980--2002
\psplot[
linecolor=blue,
algebraic
]{60}{82}{60.793*x-2619.99}% Regression with Mathematica
\end{pspicture}
\end{document}
如何在图表中显示数据?
我正在考虑使用它\pstScalePoints
来缩放 x 轴上的数据,但这只能listplot
按照手册来操作。
PS我真的很喜欢不是使用psgraph
;我不太喜欢这种语法。
答案1
\documentclass{article}
\usepackage{pst-plot}
\begin{document}
\savedata{\data}[{1924,300},{1928,510},{1932,310},{1936,880},{1948,700},
{1952,730},{1956,820},{1960,660},{1964,1100},{1968,1160},
{1972,1220},{1976,1130},{1980,1070},{1984,1300},{1988,1430},
{1992,1810},{1994,1750},{1998,2176},{2002,2399}]
\newpsstyle{gridstyle}{gridlabels=0pt,griddots=5,subgriddiv=0}
\begin{pspicture}[showgrid](-0.5,-0.5)(9.49,5.49)
\psaxes[Ox=1920,Dx=10,dx=1,Dy=500,dy=1]{->}(0,0)(9.4,5.4)[Year,0][Participants,90]
\pstScalePoints(1,1){ 1920 sub 10 div}{ 500 div }
\listplot[plotstyle=dots,dotstyle=*,linecolor=red]{\data}
% Years 1924--1976
\psplot[linecolor=blue,algebraic]{0.4}{5.6}{(15.6394*x*10+303.3)/500}% Regression with Mathematica
% Years 1980--2002
\psplot[linecolor=blue,algebraic]{6}{8.2}{(60.793*x*10-2619.99)/500}% Regression with Mathematica
\end{pspicture}
\end{document}