2

I need to

  1. put a mark on the x-axis at the point of maximum to indicate x=75.
  2. place a legend in the top left corner (above the graph to indicate "$\mu = 5$"). How can I do that with this tikz plot?
\documentclass[preprint,12pt]{elsarticle}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{graphicx}

\begin{document}

\begin{tikzpicture}
  \draw[->] (0, 0) -- (10, 0) node[right] {$x$};
  \draw[->] (0, -0.5) -- (0, 2) node[above] {$f(x)$};
  \draw[yscale=4, domain=0:10, smooth, variable=\x, blue] plot ({\x},{ exp(-7.5)*exp(exp(-7.5)+\x-exp(-7.5)*exp(\x))});
\end{tikzpicture}

\end{document}

1 Answer 1

2

Method without pgfplots (just using tikz)

MWE:

\documentclass[preprint,12pt]{elsarticle}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{graphicx}

\begin{document}

\begin{tikzpicture}
  \draw[thick] (1.5,3) node {\(\mu=5\)};
  \draw[->] (0, 0) -- (10, 0) node[right] {$x$};
  \draw[->] (0, -0.5) -- (0, 2) node[above] {$f(x)$};
  \draw[thick] (7.5, 0.1) -- (7.5, -0.1) node[anchor=north] {\(x=75\)};
  \draw[yscale=4, domain=0:10, smooth, variable=\x, blue] plot ({\x},{ exp(-7.5)*exp(exp(-7.5)+\x-exp(-7.5)*exp(\x))});
  
\end{tikzpicture}

\end{document}

Output: LaTeX output


Method using pgfplots

MWE:

\documentclass[preprint,12pt]{elsarticle}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}

\begin{document}

\begin{tikzpicture}
\begin{axis}[height=5cm,width=12cm,
             axis lines = center,
             every axis x label/.style={
                 at={(ticklabel* cs:1)},
                 anchor=west,
             },
             every axis y label/.style={
                 at={(ticklabel* cs:1)},
                 anchor=south,
             },
             xlabel = \(x\), ylabel = {\(f(x)\)},
             domain=0:10,ymin=-0.1,ymax=0.7, samples=100,
             xtick={7.5},ytick=\empty,xticklabels={\(x=75\)}]

\addplot[color=blue]{exp(-7.5)*exp(exp(-7.5)+x-exp(-7.5)*exp(x))};
\legend{\(\mu = 5\)}

\end{axis}
\end{tikzpicture}

\end{document}

Output: LaTeX output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .