# Ticks on the y axis not working as anticipated

I am trying to have a plot where the ticks on the y axis are 1, 1.004, 1.008, 1.012, 1.016, and 1.02. However, only the ticks 1, 1, 1.01, 1.01, 1.02, 1.02 are shown in the figure (see below). I was under the assumption that if we write ytick={1, 1.004, 1.008, 1.012, 1.016, 1.02} then that sets the values written at each y tick in the figure. Could someone please explain to me why this is wrong and furthermore how to have it so that the ticks in the y axis are for 1, 1.004, 1.008, 1.012, 1.016, and 1.02 ? My code is here:

\begin{figure}[ht]
\centering
\pgfplotsset{scaled y ticks=false}
\begin{tikzpicture}
\begin{axis}[name=plot, ymin=1, xtick={0, ..., 10}, ytick={1, 1.004, 1.008, 1.012, 1.016, 1.02}, xlabel={\LARGE$b_1$}]
table{./data/ratio_of_estimated_value_versus_optimal_value.txt};\label{ratio_estimated_value_versus_optimal_value}
\end{axis}
\end{tikzpicture}

\caption{Ratio of the Estimated Value of the Game and the Optimal Value of the Game}
\label{fig:my_label}
\end{figure}


• You've got a table data included here. Jun 25, 2021 at 4:04

For the decimal numbers to show up properly you should set precision=4 for displaying upto four significant figures.

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{compat=1.18}

\begin{document}
\begin{figure}[ht]
\centering
\pgfplotsset{y tick label style={/pgf/number format/.cd, scaled y ticks=false, fixed, precision=4}} %<------------ Here
\begin{tikzpicture}
\begin{axis}[name=plot, xtick={0, ..., 10}, ytick={1, 1.004, 1.008, 1.012, 1.016, 1.02}, xlabel={\LARGE$b_1$}]

• pgf/number format/.cd sets the default path to /pgf/number format. This allows you to call all the subkeys at once without needing to call everytime. Example: Instead of calling /pgf/number format/fixed,/pgf/number format/precision=2, you can shorten them to /pgf/number format/.cd, fixed, precision=2. And fixed just rounds the number to the fixed number of digits after decimal point. In this problem you really don't need it. You can use fixed zerofill instead to show trailing zeroes. Jun 25, 2021 at 19:22