使用 psgraph 和 listplot 获得“尺寸太大”

使用 psgraph 和 listplot 获得“尺寸太大”

我正在尝试设置图表。有时 y 轴值范围会变得有点窄。在其中一种情况下,我遇到了臭名昭著的“尺寸太大”错误,如下所示。

我该如何避免该错误,它似乎与 psgraph 可选参数中的集成 AXIS 参数有关。

因此...

\begin{psgraph}[optionals... going to axis](xmin,ymin)(xmax,ymax){width,length}
\end{psgraph}

我希望以下内容有资格成为 MWE...;)

   \documentclass[a4paper,12pt, headsepline, parskip, headinclude]{scrbook}
    \usepackage{pstricks-add}

    \begin{document}
        \def\dataI{%
        40 0.01
        30 0.008
        15 0.001
        0 0}

        \large Works fine\\
        \normalsize Using y-Max = 0.1 and Dy = 0.02

        \psset{xunit=1cm,yunit=1cm,plotstyle=line,tickstyle=top,axesstyle=frame}
        \begin{psgraph}[Dx=5,Dy=0.02](0,0)(0,0)(40,0.1){0.4\textwidth}{0.4\textwidth}
            \listplot[linecolor=red]{\dataI}%
        \end{psgraph}

        \large Throws an error trying to magnify \emph{y} by one magnitude

        \small\begin{verbatim}
        % ! Dimension too large.
        % <recently read> \p@ 
        %
        % l.59 ...,0)(40,0.01){0.4\textwidth}{0.4\textwidth}
        %
        % I can't work with sizes bigger than about 19 feet.
        % Continue and I'll use the largest value I can.
        \end{verbatim}
        \normalsize Using y-Max = 0.01 and Dy = 0.002

        \psset{xunit=1cm,yunit=1cm,plotstyle=line,tickstyle=top,axesstyle=frame}
        \begin{psgraph}[Dx=5,Dy=0.002](0,0)(0,0)(40,0.01){0.4\textwidth}{0.4\textwidth}
            \listplot[linecolor=red]{\dataI}%
        \end{psgraph}
    \end{document}

答案1

TeX 算法很麻烦。你可以使用以下命令缩放值\pstScalePoints

\documentclass[12pt]{scrbook}
\usepackage{pst-plot}

\begin{document}
    \def\dataI{%
    40 0.01
    30 0.008
    15 0.001
    0 0}

 \psset{plotstyle=line,tickstyle=top,axesstyle=frame,urx=2cm}
 \begin{psgraph}[Dx=5,Dy=0.02](0,0)(40,0.1){0.4\textwidth}{0.4\textwidth}
 \listplot[linecolor=red]{\dataI}%
 \end{psgraph}
 %
 \psset{plotstyle=line,tickstyle=top,axesstyle=frame}
 \pstScalePoints(1,1){}{100 mul}
 \begin{psgraph}[Dx=5,Dy=0.002,dy=0.2\psyunit](0,0)(40,1){0.4\textwidth}{0.4\textwidth}
  \listplot[linecolor=red]{\dataI}%
  \end{psgraph}
 \end{document}

在此处输入图片描述

答案2

使用 PGFPlots,您无需担心自己缩放数据。此外,您可以使用任何编译器(、、、latex... )编译文档:pdflatexxelatex

\documentclass{article}
\usepackage{pgfplots}


\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot [thick, red] table {
40 0.01
30 0.008
15 0.001
0 0
};
\end{axis}
\end{tikzpicture}
\end{document}

相关内容