I'm trying to use pgfplots to plot -3ln(x-2):





        ylabel={$g(x) = -3ln(x-2)$}
    y domain=-10:30


I'd like to display the function up until y=10, however it seems to cut off at y=2. Why is this happening?

enter image description here

  • 2
    try changing your x domain from 2:15 to something like 2.2:15. – Willie Wong Jul 20 '16 at 1:52
  • @WillieWong That did it (although I used 2.02). I guess it tries to calculate x=2 and craps out. Thank you! – Mansfield Jul 20 '16 at 1:54

I ended up taking Willie Wong's advice and used a domain of 2.02:15. It seems that since (-3)ln(x-2) is undefined for x=2 it doesn't try a different point that would display the graph appropriately.

  • 1
    I don't see why you think it would (try a different point). I mean, it evaluates the function where you've told it to, and it gets a NaN for x=2, so it does display the graph appropriately according to your specifications. By the way, you're also affected by the fact that pgfplots uses just 25 sample points by default, so the first point is calculated for x = 2, the next one for 2.54, and so on. A larger number of samples (e.g. samples=400) would also give you what you're after. – Torbjørn T. Jul 21 '16 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.