Graphics, Figures & TablesPlotting ln(x-3)^2

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Plotting ln(x-3)^2

Post by coachbennett1981 »

I am trying to plot the function ln(x-3)^2 in pstricks, but I am getting a parabolic shape graph that does not work. Does anyone know what is wrong with my code?

Code: Select all

\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
begin{pspicture}(0,-3)(5,3)
\psaxes{->}(0,0)(-4,-4)(5,4)[$x$,-90][$y$,180]
\psplot[algebraic,linecolor=red,linewidth=2pt,arrows=<->]{-4}{2.9}{ln(3-x)}
\psplot[algebraic,linecolor=blue,linewidth=2pt,arrows=<->]{3.1}{6}{ln(x-3)^2}
\uput[90](4.2,-1.5){\textcolor{red}{$f(x)=\ln(3-x)$}}
\end{pspicture}
Thank you for your time.

Nick

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Plotting ln(x-3)^2

Post by localghost »

»Does not work« is a trivial statement. Please explain what is wrong in your opinion. Supplemented to a full example I have no problem with this code.


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

Plotting ln(x-3)^2

Post by CrazyHorse »

coachbennett1981 wrote:I am trying to plot the function ln(x-3)^2 in pstricks, but I am getting a parabolic shape graph that does not work. Does anyone know what is wrong with my code?

Code: Select all

\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
begin{pspicture}(0,-3)(5,3)
\psaxes{->}(0,0)(-4,-4)(5,4)[$x$,-90][$y$,180]
\psplot[algebraic,linecolor=red,linewidth=2pt,arrows=<->]{-4}{2.9}{ln(3-x)}
\psplot[algebraic,linecolor=blue,linewidth=2pt,arrows=<->]{3.1}{6}{ln(x-3)^2}
\uput[90](4.2,-1.5){\textcolor{red}{$f(x)=\ln(3-x)$}}
\end{pspicture}
1. please provide working examples and not incomplete and
wrong ones ...

2. "that does not work" can mean anything ...

I have no problem ...

Herbert
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Plotting ln(x-3)^2

Post by coachbennett1981 »

Sorry about the "trivial statements" I need to be sure to be more complete next time.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Plotting ln(x-3)^2

Post by localghost »

coachbennett1981 wrote:Sorry about the "trivial statements" I need to be sure to be more complete next time.
And what about your problem? In case it is solved, please post the solution here. For comparison see the attachment. Don't forget to mark the topic as solved by editing your initial post and choosing the green checkmark from the icon list.
Attachments
logarithm.eps.zip
A Gnuplot graph with the two logarithmic functions.
(4.44 KiB) Downloaded 241 times
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

Plotting ln(x-3)^2

Post by CrazyHorse »

localghost wrote:
coachbennett1981 wrote:Sorry about the "trivial statements" I need to be sure to be more complete next time.
And what about your problem? In case it is solved, please post the solution here. For comparison see the attachment. Don't forget to mark the topic as solved by editing your initial post and choosing the green checkmark from the icon list.
a PSTricks output looks nicer than a gnuplot one ... ;)

Herbert
Attachments
PSTricks output
PSTricks output
x.png (7.75 KiB) Viewed 5945 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Plotting ln(x-3)^2

Post by localghost »

CrazyHorse wrote:[...] a PSTricks output looks nicer than a gnuplot one [...]
Of course I'm aware of this fact. The plot has been attached only for comparison since the OP mentioned something about a parabolic shape which sounded to me like he was not sure if he got the right output. The difference in quality is out of question. And I would have done the graph just like you did, but in a psgraph environment.
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Plotting ln(x-3)^2

Post by coachbennett1981 »

Thank you guys
Post Reply