Graphics, Figures & Tablespst-plot | Logarithmic Graph

Information and discussion about graphics, figures & tables in LaTeX documents.
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

pst-plot | Logarithmic Graph

Post by Mini »

Hello,

I've tried doing this using \psplot[plotpoints=1000]{1.2}{2.5}{(x+3)*(x+1)*(x-1) 0.4343 div} and some other algebraic variants, with no success.

How do I plot ln ((x+3)*(x+1)*(x-1))?

Thanks

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

pst-plot | Logarithmic Graph

Post by CrazyHorse »

Mini wrote:Hello,

I've tried doing this using \psplot[plotpoints=1000]{1.2}{2.5}{(x+3)*(x+1)*(x-1) 0.4343 div} and some other algebraic variants, with no success.

How do I plot ln ((x+3)*(x+1)*(x-1))?
next time it is your turn to provide a _full_ working example.
You cannot mix algebraic and postscript notation.

Code: Select all

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

\begin{document}

\begin{pspicture}(-5,-5)(2.2,5.2)
\psset{yunit=0.5}
\psaxes[Dy=2](0,0)(-5,-10)(2,10)
\psplot[plotpoints=5000,algebraic,linewidth=1.5pt,
  yMaxValue=10]{-5}{5}{(x+3)*(x+1)*(x-1)/0.4343} 
\end{pspicture}

\end{document}
Herbert
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

Re: pst-plot | Logarithmic Graph

Post by Mini »

Hi,

Thanks for your reply. But I need ln[(x+3)*(x+1)*(x-1)].

Also by a full working example, do you mean that I should provide code for the whole text document (ie. compilable)?

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

pst-plot | Logarithmic Graph

Post by CrazyHorse »

Mini wrote:Hi,

Thanks for your reply. But I need ln[(x+3)*(x+1)*(x-1)].

Also by a full working example, do you mean that I should provide code for the whole text document (ie. compilable)?
yes, if it runs otherwise as complete code which shows the specific error.

Code: Select all

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

\begin{document}

\begin{pspicture}(0,-5)(5.5,5.2)
\psset{yunit=0.5}
\psaxes[Dy=2](0,0)(0,-10)(10,10)
\psplot[plotpoints=5000,algebraic,
   linewidth=1.5pt]{1.0001}{10}{ln((x+3)*(x+1)*(x-1))}
\end{pspicture}

\end{document}
Herbert
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

pst-plot | Logarithmic Graph

Post by Mini »

Hello again,

I'm having trouble again with shading areas...

I want to shade the area between x=0, x=2, the axis and the graph y=2ln(x+1).

Below is my code; what am I doing wrong?

Code: Select all

\documentclass[12pt, a4paper, fleqn, leqno]{article}
\pagestyle{empty}
\linespread{1.5}
\usepackage{polynom}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage[lmargin=1cm, rmargin=1cm, tmargin=1cm, bmargin=1cm]{geometry}
\usepackage{pst-eucl}
\newcommand{\cosec}{\operatorname{cosec}}

\begin{document}

\begin{pspicture}(-2,-2)(4,3)
    %\psset{unit=2cm}
    \psaxes[linewidth=1.2pt, labels=none, ticks=none]{->}(0,0)(-2,-2)(4,3)[$x$,-90][$y$,180]
    \psplot[algebraic=true,plotpoints=1000,arrows=<->]{-0.6}{3}{2*(ln(x+1))}
    \psline[linestyle=dashed](-1,3)(-1,-2)
    
    \psline(2,0)(2,2.197224578)
    
    \pscustom[fillstyle=vlines,linestyle=none]{%
      \psplot[algebraic=true,plotpoints=1000]{0}{2}{2*(ln(x+1))}
      \psline(2,0)(2,2.197224578)
    }
\end{pspicture}

\end{document} 
Thanks!
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

pst-plot | Logarithmic Graph

Post by CrazyHorse »

Mini wrote: I want to shade the area between x=0, x=2, the axis and the graph y=2ln(x+1).

Below is my code; what am I doing wrong?
you have to draw a continous line for the shaded area, the resaon why you have to start \psline with the end value of the curve.
However, with enabled \SpecialCoor you also can use the algebraic calculation of y values:

Code: Select all

\documentclass{minimal}
\pagestyle{empty}
\usepackage{pst-plot}\SpecialCoor

\begin{document}

\begin{pspicture}(-2,-2)(4,3)
    \psaxes[linewidth=1.2pt, labels=none, ticks=none]{->}(0,0)(-2,-2)(4,3)[$x$,-90][$y$,180]
    \psplot[algebraic=true,plotpoints=1000,arrows=<->]{-0.6}{3}{2*(ln(x+1))}
    \psline[linestyle=dashed](-1,3)(-1,-2)
    \psline(2,0)(2,2.197224578)  
    \pscustom[fillstyle=vlines,linestyle=none]{%
      \psplot[algebraic=true,plotpoints=1000]{0}{2}{2*(ln(x+1))}
      \psline(*2 2*ln(x+1)(2,0)}
\end{pspicture}

\end{document} 
Herbert
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

pst-plot | Logarithmic Graph

Post by Mini »

Hi again,

Thanks for that I really do appreciate it. I have another one though... this time the x-cord is irrational... I would like to shade the area between x=-root5, x=root5 and the curve y=root(9-x^2) [ignore the elliptic arc for now]. How would I use special coords for that?

Code: Select all

\documentclass[12pt, a4paper, fleqn, leqno]{article}
\pagestyle{empty}
\linespread{1.5}
\usepackage{polynom}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage[lmargin=1cm, rmargin=1cm, tmargin=1cm, bmargin=1cm]{geometry}
\usepackage{pst-eucl}
\newcommand{\cosec}{\operatorname{cosec}}

\begin{document}

\begin{pspicture}(-4,-1)(4,4)
    %\psset{unit=1.5cm}
    \psaxes[linewidth=1.2pt, labels=none, ticks=none]{->}(0,0)(-4,-1)(4,4)[$x$,-90][$y$,180]

    \psarc(0,0){3}{0}{180}
    
    \psline(-2.236067977,0)(-2.236067977,2)
    \psline(2.236067977,0)(2.236067977,2)
    \psellipse(0,2)(2.236067977,0.3)
    
    \psdot(2.236067977,2)
    \rput(3,2.1){$(\sqrt{5},2)$}
    
    \rput(2,3.5){$y=\sqrt{9-x^2}$}
    \psline{->}(2.3,3.3)(1.3,2.72)
    
    \pscustom[fillstyle=vlines,linestyle=none]{%
      \psline(-2.236067977,0)(-2.236067977,2)
      \psarc(0,0){3}{0}{180}
      \psline(2.236067977,0)(2.236067977,2)
    }
\end{pspicture}
\end{document}
Thanks
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

pst-plot | Logarithmic Graph

Post by CrazyHorse »

Mini wrote: Thanks for that I really do appreciate it. I have another one though... this time the x-cord is irrational... I would like to shade the area between x=-root5, x=root5 and the curve y=root(9-x^2) [ignore the elliptic arc for now]. How would I use special coords for that?
it is a bit overkill here to calculate every value. However, when using the
algebraic option * for special coordinate you have to mix the types of coordinates: the x value must in PostScript notation, whereas the function must be in algebraic notation. If this contains parenthesis, then you have to put it into braces. Same for the x value if it contains a space:

Code: Select all

\psline(*{5 sqrt neg} {sqrt(9-x^2)})(!5 sqrt neg 0)
The angles for the arc can also be written as special coordinates.
And, by the way, please provide minimal examples ...

Code: Select all

\documentclass{minimal}
\usepackage{pst-plot}\SpecialCoor

\begin{document}

\begin{pspicture}(-4,-1)(4,4)
    %\psset{unit=1.5cm}
    \psaxes[linewidth=1.2pt, labels=none, ticks=none]{->}(0,0)(-4,-1)(4,4)[$x$,-90][$y$,180]

    \psarc(0,0){3}{0}{180}
   
    \psline(-2.236067977,0)(-2.236067977,2)
    \psline(2.236067977,0)(2.236067977,2)
    \psellipse(0,2)(2.236067977,0.3)
   
    \psdot(2.236067977,2)
    \rput(3,2.1){$(\sqrt{5},2)$}
   
    \rput(2,3.5){$y=\sqrt{9-x^2}$}
    \psline{->}(2.3,3.3)(1.3,2.72)
   
    \pscustom[fillstyle=vlines,linestyle=none]{%
      \psline(!5 sqrt 0)(*{5 sqrt} {sqrt(9-x^2)})
      \psarc(0,0){3}{!2 5 sqrt atan}{!2 5 sqrt neg atan }
      \psline(*{5 sqrt neg} {sqrt(9-x^2)})(!5 sqrt neg 0)
    }
\end{pspicture}
\end{document}


Herbert
Attachments
x.png
x.png (4.14 KiB) Viewed 8367 times
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

Re: pst-plot | Logarithmic Graph

Post by Mini »

Thanks heaps for your help CrazyHorse! You're the man!

Btw how did you export the graphic to PNG?

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

pst-plot | Logarithmic Graph

Post by CrazyHorse »

Mini wrote: Btw how did you export the graphic to PNG?
that was only taken from my screen

Herbert
Post Reply