2

I managed to adjust some of the existing code a little bit to fit my needs. I can plot simple functions.

(1) I want to add labels to the coordinate system, for example e (~ 2.71) to the x-axes and 1/e.

(2) Furthermore I like to label special points on the function graphs. For example at the coordinate x=e and y=1.

\documentclass[13pt,a4paper,headlines=6,headinclude=true]{scrartcl}

\usepackage{amsmath,amssymb,stmaryrd}       
\usepackage{tikz,pgfplots}
\usetikzlibrary{datavisualization.formats.functions}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{tikzpicture}[yscale=.5, xscale=.5, scale=2]
\datavisualization
[school book axes,
legend={below,rows=1},
visualize as smooth line/.list={f1,f2,f3},
f1={style=blue, style=very thick,label in legend={text=$e^x$}},
f2={style=green, style=very thick,label in legend={text=$ln(x)$}},
f3={style=red, style=very thick,label in legend={text=$x$}}
]
data [set=f1, format=function] {
var x : interval[-5:2];
func y = e^(\value x);
}data [set=f2, format=function] {
var x : interval[0.1:5];
func y = ln(\value x);
}data [set=f3, format=function] {
var x : interval[-3:3];
func y = (\value x);
};
\end{tikzpicture}   


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Thank you :)

enter image description here

  • From a typographical point of view, It would be better to replace $ln(x)$ by $\ln(x)$. – Franck Pastor Apr 23 '15 at 9:51
  • Of course this is right. Thank you for your remark. – Mac Apr 23 '15 at 12:57
4

By adding these lines:

 \draw[shift={(e,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$e$};
 \path[draw=red, dashed] (e,0) -- (e,1);
 \path[draw=red, dashed] (0,1) -- (e,1);
 \node[outer sep=0pt,circle, fill=red,inner sep=1.5pt] (P) at (e,1) {};

I got this: enter image description here

  • 1
    While code is useful, explanations about what it is doing, what was missing from the MWE in the question, etc. is always welcome. – T. Verron Apr 22 '15 at 19:37
  • \draw adds the axes-label. \node gives the circle on the line and \path optionally adds the dashed lines to make this more clear. This is perfectly what I was looking for. But is there some good tutorial or something that gives more variants on how the \shift etc. works? – Mac Apr 23 '15 at 13:07
  • Give a look at: texample.net/tikz/examples/tag/plots – Arianna Angeletti Apr 23 '15 at 13:45

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.