Dear TeX StackExchange,
I am trying to plot two functions in the same grid. The code I currently have is below:
\begin{center}
\begin{tikzpicture}[scale=1, transform shape]
\begin{axis}[grid=both,
mark = none,
xmin = 0, ymin = 0,
xmax = 16,ymax = 16,
axis lines*=middle,
enlargelimits,
xtick={0,2,...,16},
ytick={0,2,...,16}]
\addplot[red, domain=0:5, samples=100] {pow(2,x)} node[pos=0.52, right]{$y=2^n$};
\addplot[blue, domain=0:18, samples=100] {x} node[pos = 0.89, above left] {$y=n$};
\end{axis}
\end{tikzpicture}
\end{center}
The code below gets plotted as:
however, I would like the grey lines not to overlap the x- and y-axis, but the graph should not change otherwise - when I tried axis lines *= left
, it got shifted a little bit, as can be seen here (which is something I do not want):
which is something I want to achieve partially (the axis are fixed), however the plots do not look like on the first picture (since they are shifted).
Any ideas?
enlargelimits=false,
orenlargelimits=upper
.enlargelimits=upper
works without having to set the position manually again.