绘制多条线

绘制多条线

我已经从数据生成了 pstricks 代码:

\psset{unit=10cm}
\begin{pspicture}(0,0)(1,1)
    \psline(0.22029880495812262,0.23497192515414284)(0.21975600857793104,0.23394684903842253)
    \psline(0.2584529413334904,0.22000887379324077)(0.2551267563022901,0.21319288260584074)
    \psline(0.2584529413334904,0.22000887379324077)(0.2591309918937222,0.22175303315432685)
    \psline(0.3833672951833354,0.13344349076667328)(0.38201653304384925,0.13337464237083807)
    \psline(0.574041875405995,0.2843744740747551)(0.5783130600368138,0.2848105139150266)
    \psline(0.574041875405995,0.2843744740747551)(0.5708758597984268,0.28412967977846876)
    \psline(0.5611001859745068,0.3016936705374795)(0.5624740836974276,0.30102813604442846)
    \psline(0.5611001859745068,0.3016936705374795)(0.5599451864639463,0.30213736019950443)
    \psline(0.33774570434501133,0.15330242805342456)(0.336387823564517,0.15383026575480516)
    \psline(0.22830905580127048,0.252222273221032)(0.22817380162135673,0.25358394149416136)
    % about 9000 more lines
\end{pspicture}

但是 LaTeX 给出了内存不足的错误。

有没有更好的(消耗更少内存的)方法来创建这个由大约 9000 条小线(每条两个坐标)组成的图?


数据可以在这里下载:https://paste.ee/p/q08ru(格式:x0,y0 x1,y1)

答案1

这些行真的很短,使用情节样式更有意义dots

    \documentclass[pstricks,border=10pt]{standalone}
    \usepackage{pst-plot}
    \begin{document}

    \psset{unit=10} 
    \readdata\Data{pstricks.data}
    \begin{pspicture}(-0.1,-0.1)(1.1,1.1)
    \psaxes[Dx=0.2,Dy=0.2,labelFontSize=\scriptstyle]{->}(1,1.05)
    \listplot[plotstyle=dots,dotsize=1pt]{\Data}
    \end{pspicture}
    \end{document}   

如果您仍然需要这些线条,那么您必须增加 TeX 输入缓冲区或在 PostScript 级别创建解决方案。

这里有一个需要数据文件的解决方案没有坐标之间的逗号(可以简单地用空格代替)。

\documentclass[pstricks,border=10pt]{standalone}
\usepackage{pst-plot}
\begin{document}

\psset{unit=10} 
\makeatletter
\begin{pspicture}(-0.1,-0.1)(1,1)
\psaxes[Dx=0.2,Dy=0.2,labelFontSize=\scriptstyle]{->}(0.8,0.8)
\pscustom{
  \code{
  [ (pstricks.data) run ] /Points exch def  % save data
  Points length 4 div cvi /No exch def      % No of lines
  1 setlinewidth
  1 0 0 setrgbcolor
  0 4 No { 
    /iNo exch def
    Points iNo 4  getinterval aload pop 
    \tx@ScreenCoor
    4 2 roll \tx@ScreenCoor
    moveto lineto stroke
  } for 
  }
}
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容