Question
Is there a way to include mathematical expressions in PGFPlots, for example, [domain=1/3:e^5/3]
?
PGFPlots is fairly useful, however the ability to put mathematical expressions directly into Tikz makes life much easier.
The only way around this problem that I know of is to define a bunch of constants above the before entering the axis environment
. I find this a little obnoxious.
MWE
\documentclass{memoir}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{amsmath}
\usetikzlibrary{calc, positioning}
\begin{document}
\begin{tikzpicture}[domain=1/3:e^5/3,x=0.1cm, scale=1]
% Axes
\draw[help lines] (-0.2 cm,0) -- (e^5/3+0.2,0) node[right] {$x$};
\draw[help lines] (0,-0.2) -- (0,6) node[above] {$y$};
\draw[gray, thick] (e^5/3,5) -- (-0.075/0.1,5) node[left] {$y=5$};
\draw[gray, thick] (e^5/3,4) -- (-0.075/0.1,4) node[left] {$y=4$};
% Curves
\draw[blue, thick] plot[id=lnx] (\x,{ln(3*\x)}) node[right] {$\ln 3x$};
\end{tikzpicture}
\end{document}
\addplot[domain=1/3:e^5/3] {ln(3*x)}
inpgfplots
: it applies the math parser. That said, there are still lots of places where the math parser should be invoked... a relic of times when the floating point unit was unavailable.xmode=log,domain=1/3:e^5/3
leads toCould not parse input '1/3' as a floating point number
. Is there a way around that?\begin{semilogyaxis}[xmin=-1, xmax=e^5/3+5,] ...
and you'll run into issues! This is likely one of those places where the math parser could stretch its legs a little.\pgfmathsetmacro
expressions. Hehehe