# How to add help line and background color by tikz

everyone:

I want to use tikz to draw a figure like this one:

But I don't know how to add help line and background color So I just get this figure:

How can I change my code? anyone can help me?

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xtick={0,40,...,160},
ymin=0,
ymax=12,
xmin=0,
xmax=180,
grid style=dashed,
yticklabel style = {font=\tiny},
xticklabel style = {font=\tiny},
legend style={draw=none,font=\tiny,legend pos=south east,cells={anchor=west}}
]

color=blue,
mark=square,
]
coordinates {
(40,8.35)
(60,7.87)
(80,7.51)
(100,7.32)
(120,7.15)
(140,7.02)
(160,6.97)
};
\addlegendentry{S$_1+$ S$_2$= 200}

color=red,
mark=square,
]
coordinates {
(40,9.54)
(60,9.35)
(80,8.77)
(100,8.81)
(120,8.66)
(140,8.29)
(160,8.59)
};
\addlegendentry{S$_1+$ S$_2$= 300}

\end{axis}
\end{tikzpicture}
\caption{Comparison of S}
\label{step_decay_test_performance}
\end{figure}

\end{document}


You've set the grid style, but you haven't actually activated the grid. Add grid to the axis options. To set the background colour, axis background/.style={fill=blue!10}. If you want the legend to have the same colour, add the same fill to the legend style.

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xtick={0,40,...,160},
ymin=0,
ymax=12,
xmin=0,
xmax=180,
grid style=dashed,
yticklabel style = {font=\tiny},
xticklabel style = {font=\tiny},
legend style={draw=none,font=\tiny,legend pos=south east,cells={anchor=west}},
]

color=blue,
mark=square,
]
coordinates {
(40,8.35)
(60,7.87)
(80,7.51)
(100,7.32)
(120,7.15)
(140,7.02)
(160,6.97)
};
\addlegendentry{S$_1+$ S$_2$= 200}

color=red,
mark=square,
]
coordinates {
(40,9.54)
(60,9.35)
(80,8.77)
(100,8.81)
(120,8.66)
(140,8.29)
(160,8.59)
};
\addlegendentry{S$_1+$ S$_2$= 300}

\end{axis}
\end{tikzpicture}
\caption{Comparison of S}
\label{step_decay_test_performance}
\end{figure}

\end{document}