Graphics, Figures & Tablespsgraph decimal

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
achim
Posts: 49
Joined: Wed Aug 05, 2009 2:29 pm

psgraph decimal

Post by achim »

Hi all

After years of searching and often also finding answers to my LaTeX problems I have decided to finally register to a forum. HELLO ALL!

My first topic is about plotting with psgraph.

I have the following code:

Code: Select all

\documentclass[12pt,a4paper]{article}

\usepackage{pstricks}                           % Graphics package for plots
\usepackage{pst-all}                            % Graphics package for plots
\usepackage{pstricks-add}                       % Graphics package for plots

\begin{document}

\begin{figure}[h!]
    \begin{center}
        \begin{psgraph}[axesstyle=frame, Dx=1, Dy=0.1, xsubticks=5, ysubticks=5](0.,0.)(-6.,0.)(6.,1.4){0.9\linewidth}{6cm}
        
        \end{psgraph}
    \caption{First Variable $z1$}
    \end{center}
\end{figure}

\end{document}
The problem is the plot range in y.

\begin{psgraph}[axesstyle=frame, Dx=1, Dy=0.1, xsubticks=5, ysubticks=5](0.,0.)(-6.,0.)(6.,1.4){0.9\linewidth}{6cm}

I want to plot to y=1.4 which works but in the "bl" corner you can see ".4" which is not there when I choose y to be an integer, so it must origin form there.
When I set y to eg. 0.4 I can't even compile it. I get:
! Arithmetic overflow.
<to be read again>
.
l.159 ....,0.)(-6.,0.)(6.,0.4){0.9\linewidth}{6cm}

I can't carry out that multiplication or division,
since the result is out of range.
How can I solve this problem?

Thanks
Last edited by achim on Mon Aug 17, 2009 3:04 pm, edited 2 times in total.
OS: Kubuntu
Distribution: TexLive
Editor: Kile

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

psgraph decimal

Post by CrazyHorse »

achim wrote: The problem is the plot range in y.

\begin{psgraph}[axesstyle=frame, Dx=1, Dy=0.1, xsubticks=5, ysubticks=5](0.,0.)(-6.,0.)(6.,1.4){0.9\linewidth}{6cm}

I want to plot to y=1.4 which works but in the "bl" corner you can see ".4" which is not there when I choose y to be an integer, so it must origin form there.
When I set y to eg. 0.4 I can't even compile it. I get:
! Arithmetic overflow.
<to be read again>
.
l.159 ....,0.)(-6.,0.)(6.,0.4){0.9\linewidth}{6cm}

I can't carry out that multiplication or division,
since the result is out of range.
How can I solve this problem?
you have an old version of pstricks-add. I have no problem with this
slightly modified version

Code: Select all

\listfiles
\documentclass[12pt,a4paper]{article}
                           
\usepackage{pstricks-add} 

\begin{document}

\begin{figure}[!htb]
\centering
\psset{lly=-5mm}
\begin{psgraph}[axesstyle=frame, Dx=1, Dy=0.2, 
  subticks=5](0.,0.)(-6.,0.)(6.,1.4){0.9\linewidth}{6cm}
       
\end{psgraph}
\caption{First Variable $z1$}
\end{figure}

\end{document}

*File List*
article.cls 2005/09/16 v1.4f Standard LaTeX document class
size12.clo 2005/09/16 v1.4f Standard LaTeX file (size option)
pstricks-add.sty 2009/03/17 v. 0.13 package wrapper for pstricks-add.tex (hv
)
pstricks.sty 2008/11/26 v0.40 LaTeX wrapper for `PSTricks' (RN,HV)
pstricks.tex 2009/05/19 v1.29 `PSTricks' (tvz,hv)
pstricks.pro 2009/01/30 v. 1.06, PostScript prologue file (hv)
pst-dots.pro 2006/12/19 v. 2.00, PostScript prologue file (hv)
pst-algparser.pro 2008/01/01 v. 0.01, PostScript prologue file (hv)
xcolor.sty 2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
dvips.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
pstricks-add.tex 2009/06/08 v3.35 `PSTricks-add' (hv)
pst-xkey.tex 2005/11/25 v1.6 PSTricks specialization of xkeyval (HA)
xkeyval.sty 2008/08/13 v2.6a package option processing (HA)
xkeyval.tex 2008/08/13 v2.6a key=value parser (HA)
pstricks-add.pro 2009/03/17 v. 0.22, PostScript prologue file (hv)
pstricks-add.cfg 2005/01/10 v0.1 addtional user stuff (hv)
***********

Herbert
achim
Posts: 49
Joined: Wed Aug 05, 2009 2:29 pm

Re: psgraph decimal

Post by achim »

Thank you Herbert

You're right it was an old version of pstricks-add.
It's working fine now.

Cheers!
OS: Kubuntu
Distribution: TexLive
Editor: Kile
achim
Posts: 49
Joined: Wed Aug 05, 2009 2:29 pm

psgraph decimal

Post by achim »

I am still not completely comfortable with the syntax in \psgraph.

I am trying the following plot:

Code: Select all

\savedata{\dataone}[
{{10,1.045},{15,1.025},{20,1.011},{25,1.007},{30,1.005},{40,1.003},{50,1.002},{80,1.001}}
]

\savedata{\datatwo}[
{{10,0.958},{15,0.989},{20,0.990},{25,0.993},{30,0.995},{40,0.997},{50,0.998},{80,0.999}}
]

\begin{figure}[!thb]
    \begin{center}
        \psset{lly=-5mm, ury=5mm, xAxisLabel=$N$, yAxisLabel=$R$}
        %\pstScalePoints(1,1){}{0.95 sub}
        \begin{psgraph}[axesstyle=frame, Oy=0.95, Dx=10, Dy=0.025, subticks=5, ticksize=-4pt 0]%
            (0.,0.95)(85.,1.05){0.7\linewidth}{6cm}
            \dataplot[showpoints=true,dotstyle=Bo]{\dataone}
            \dataplot[showpoints=true,dotstyle=Btriangle]{\datatwo}
        \end{psgraph}
    \caption{Error $e$ as a function of the number of elements $N$}
    \label{fig: error plot}
    \end{center}
\end{figure}
where the y axis should range form 0.95 to 1.05 but it goes up to 1.95.
I was playing with \pstScalePoints but couldn't get it to work. I'd rather not use the \pstScalePoints function since I find itvery confusing.

What is the problem with the above code?

Thanks

ps:I have updated to the new pstricks version...
OS: Kubuntu
Distribution: TexLive
Editor: Kile
achim
Posts: 49
Joined: Wed Aug 05, 2009 2:29 pm

psgraph decimal

Post by achim »

I found the solution in a mailing list.
Of course solved by the one and only; Herbert!

It was a rounding problem as suggested here:
http://www.tug.org/pipermail/pstricks/2005/002423.html

This just for reference...
OS: Kubuntu
Distribution: TexLive
Editor: Kile
Post Reply