# Exponential Function with “wrong” Plot in PGFPlots

While experimenting with PGFPlots, I found out a little weird issue:

I want to plot the function given by f(x) = 2^x, so I type:

\begin{tikzpicture}
\begin{axis}[   axis x line = center,
axis y line = center,
xmin = 0,
xmax = 4,
xlabel = {$x$},
ylabel = {$y$},
ticks = none,
width=6cm]

domain = 0:3]
plot (\x,{2^(\x)});
\end{axis}
\end{tikzpicture}


Which results in: At first, I am happy the code works but upon a closer look, I realize that PGF says f(0)= 2^0 = 0, which is obviously wrong, as it should be 1. I tried to play with the parenthesis in the line:

    plot (\x,{2^(\x)});


But it didn't work. What could be causing this? I have suspected that it's some kind of scaling issue (as if the plot was zoomed out a lot), since I used the width=6cm option, but removing that doesn't seem to solve it. Any suggestions?

• put the ticks back on and you'll see and then add ymin=0 – percusse Mar 19 '16 at 4:18

As percusse already mentioned in his comment this is because of the combination of options you have (not) used, i.e. providing ticks=none but not setting ymin. Turning back on the ticks and/or setting ymin will show you, that PGFPlots calculates the right values.

Also I want to note that you can simplify the equation you give to the \addplot handler. "Your version" is mainly used for parametric plots.

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=center,
axis y line=center,
xmin=0,
xmax=4,
xlabel={$x$},
ylabel={$y$},
%           ticks = none,
smooth,
domain=0:3,
]
% original version
% simplified version • plot is also not needed – percusse Mar 19 '16 at 6:49
• I'm really new to PGFPlots, so I wasn't aware these options were necessary to better build the plot. One question about your simplified version: What does the + after \addplot do? Also, why are you using [only marks, mark size = 1pt]? – Guilherme Vargas Mar 19 '16 at 13:23
• @GuilhermeVargas, the + says that the following options should be appended to the default style of this plot; that is why for example the color is still red. Otherwise only the applied options are used for the plot. I added the options so that for that plot no line is drawn between the points (only marks) and I set the size of the markers, as the name suggests. – Stefan Pinnow Mar 19 '16 at 13:28