I want to draw this function: |x - 4| + 1, but it looks like this: enter image description here

Instead of this:

enter image description here

Here is part of my .tex file

    \begin{axis}[axis lines=middle, samples=200, xtick={-4,-3,...,10}, ytick={-4,-3,...,10}]
        \addplot[thick, domain=-4:8] {(abs(x - 4)) + 1};

I don't know what I'm doing wrong. Thanks in advance for the help!


Add ymin=0 to your axis spec... (or ymin=-0.5 perhaps)


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.