1

I have two problems with the following plot:

Output of the MWE

\documentclass{article}

\usepackage{pgfplots} 

\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[
  grid = none,
  tick style = {black},
  ticklabel style = {/pgf/number format/.cd, use comma, fixed, fixed zerofill},
  % x axis
  xmin = 0, xmax = 0.01,
  axis x line = middle, x axis line style = -{Stealth},
  xlabel = $p$, xlabel style = {below},
  xtick = {0, 0.001, ..., 0.01}, xticklabels = {},
  extra x ticks = {0.001},
  xticklabel style = {/pgf/number format/.cd, precision = 3},
  % y axis
  ymin = 0, ymax = 1.1,
  axis y line = middle, y axis line style = -{Stealth},
  ylabel = $P(X \ge 10)$, ylabel style = {left},
  ytick = {0, 0.1, ..., 1.1}, yticklabels = {},
  extra y ticks = {0.1}
]
\addplot[domain = 0 : 0.01, samples = 1000] {0.8};
\end{axis}
\end{tikzpicture}

\end{document}
  1. The MWE produces three errors. They seem to be related to the /pgf/number format/.cd command. If I specify the full path for each item, the errors disappear. What am I doing wrong here? The syntax seems to be similar to an example on page 339 of the manual.
  2. How can I get rid of the \cdot 10^{-2} legend?

1 Answer 1

1

It works if you specify /pgf/number format/ for each key, instead of using .cd:

ticklabel style = {
      /pgf/number format/use comma,
      /pgf/number format/fixed,
      /pgf/number format/fixed zerofill
  },

Alternatively you can use .cd again to change back to /pgfplots as the root key family, i.e.

ticklabel style = {
      /pgf/number format/.cd,
      use comma,
      fixed,
      fixed zerofill,
      /pgfplots/.cd
},

For 2., add scaled ticks=false.

\documentclass{article}

\usepackage{pgfplots} 

\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[
  grid = none,
  tick style = {black},
  ticklabel style = {
      /pgf/number format/use comma,
      /pgf/number format/fixed,
      /pgf/number format/fixed zerofill
  },
  % x axis
  xmin = 0, xmax = 0.01,
  axis x line = middle, x axis line style = -{Stealth},
  xlabel = $p$, xlabel style = {below},
  xtick = {0, 0.001, ..., 0.01}, xticklabels = {},
  extra x ticks = {0.001},
  xticklabel style = {
     /pgf/number format/precision = 3
  },
  % y axis
  ymin = 0, ymax = 1.1,
  axis y line = middle, y axis line style = -{Stealth},
  ylabel = $P(X \ge 10)$, ylabel style = {left},
  ytick = {0, 0.1, ..., 1.1}, yticklabels = {},
  extra y ticks = {0.1},
  % add this:
  scaled ticks=false
]
\addplot[domain = 0 : 0.01, samples = 1000] {0.8};
\end{axis}
\end{tikzpicture}

\end{document}

You must log in to answer this question.

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