I am trying to graph y=e^(1/x) using PGF/TikZ.

I have been unsuccessful in solving the following three problems:

  1. I want the axis labels to look nice

I want the y-axis label to be at the top right of the y-axis like in a book

Similarly, I want the x-axis label to be at the bottom right of the x-axis

Currently, they are not in these places, and do not look "nice"

  1. I would like to make the discontinuity smaller, so it is more aesthetically pleasing.

  2. How do I remove the tick marks on the y-axis?

Below is a short executable example. I removed a lot of the extra packages, but some are present; I didn't feel fully confident going in and making big changes to these parts of the preamble.

Thank you very much for taking the time to help me get past these roadblocks, and for overlooking some of the not-so-minimal parts of the following code.






    axis line style = thick,
    trig format=rad,
    axis x line=middle,
    axis y line=middle,
    enlarge x limits=0.15,
    enlarge y limits=0.15,
    every axis x label/.style={at={(current axis.right of origin)},anchor=north west}
    every axis y label/.style={at={(current axis.above origin)},anchor=south east}
    ticklabel style={font=\tiny,fill=white}

    xmin=-2, xmax=4,
    axis lines=middle,
    x label style={at={(ticklabel cs:1)},anchor=north},
    y label style={at={(ticklabel cs:1)},rotate=0,anchor=west},
    %\clip (-2,-2) rectangle (4,2);
    \addplot [
    \addplot[mark=*, fill=black, forget plot] coordinates{(-0.5,0.136)};
    \addplot [
    \addplot[mark=*, fill=white, forget plot] coordinates{(0,0)};
    \addplot [
    \path[draw,dashed] (-2,1) -- (4,1);
  • Welcome to TeX.SE!
    – Mensch
    Oct 1 at 20:11

1 Answer 1

  • your document example is not minimal, in preamble are loaded many unrelated package and defined unrelated commands. In my MWE I remove all of them,
  • you have many questions, you should focused to one only ...
  • it is not entirely clear, what you after, so I guess, that you looking for something like this:

enter image description here

This figure is produced by the following MWE (Minimal Working Example, a small but complete, compilable document):


%\usepgfplotslibrary{statistics}    % not used in this example
%\usepgfplotslibrary{fillbetween}   % not used in this example


    axis lines=middle,
    ymin=-1, ymax=10, 
    ytick=\empty,  % <--- changed
    tick label style={font=\footnotesize},
    label style={below left},
    restrict y to domain=-2:100,    % <------ added
    every axis plot post/.append style={very thick},
    \addplot [domain=-2:4] {e^(1/x)};
    \path[draw,dashed] (-2,1) -- (4,1);
  • pgfplotstable is not needed Oct 2 at 0:07
  • @hpekristiansen, you are right. Corrected now.
    – Zarko
    Oct 2 at 6:18
  • Good day, Zarko, thank you for taking the time to let me know about your experience regarding my MWE. I greatly appreciate you sharing your feedback. Again, I understand your frustration, and I sincerely apologize for any inconvenience I have caused you. Oct 2 at 6:19
  • @Tyler, you are welcome! Does my answer solve your problem? If yes, you may consider to accept it (by clicking on check mark at tope left side of the answer).
    – Zarko
    Oct 2 at 6:29
  • I am grateful to you for taking the time to read and answer my question, as well as make suggestions. The axis labels are in the right spot and the ticks are gone. I still need to figure out how to scale down the discontinuity notation, but I'll try to figure that out myself. Thanks! Oct 2 at 6:41

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.