6

I plotted the following function:

enter image description here

Here is the script used:

    \documentclass[a4paper, 11pt]{article}
    \usepackage{tikz,pgfplots}
    \begin{document}
    \begin{tikzpicture}[>=latex]
    \begin{axis}[
    axis x line=bottom,
    axis y line=left,
    xlabel={traffic load},
    ylabel={M},
    xtick={0,1,...,5},
    ytick={0,1,...,5},
    ]
    \addplot [mark=none,draw=blue]
    coordinates {(0,0)(1,0)(1,1)(2,1)(2,2)(3,2)(3,3)(4,3)};
   \end{axis}
   \end{tikzpicture}
   \end{document}

I want that instead of having numbers in ticks, to have something that looks like:

enter image description here

How can I get the math mode in the ticks ?

11

You can use xticklabels and yticklabels for that.

\documentclass[a4paper, 11pt]{article}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}[>=latex]
\begin{axis}[
axis x line=bottom,
axis y line=left,
xlabel={traffic load},
ylabel={$M$},xmax=4.5,ymax=3.5,
xtick={1,4},xticklabels={$\rho_\mathrm{min}$,$\rho_\mathrm{max}$},
ytick={0,3},yticklabels={$0$,$M_\mathrm{max}$}
]
\addplot [mark=none,draw=blue]
coordinates {(0,0)(1,0)(1,1)(2,1)(2,2)(3,2)(3,3)(4,3)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

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.