0

I have the following plot in Excel that I want to reproduce as much as possible on Latex.

enter image description here

However, so far I have this:

enter image description here

Besides of the labels, the axis ticks are wrong as well as the plot itself. Can anyone help me, please?

My MWE is

\documentclass[a4paper,11pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{siunitx} 
\usepackage{pgfplots}
\usetikzlibrary{intersections, calc}
\pgfplotsset{compat=1.14}
\begin{document}

\begin{figure}[h!]
\begin{center}
\begin{tikzpicture}[scale=0.8]
\centering
\begin{axis}[
width= \linewidth,
height = 9cm,
%grid = major,
axis x line = center,
axis y line = center,
xticklabels = {Oct 13, Nov 13, Dec 13, Jan 2014, Feb 14, Mar 14, Apr 14, May 14, Jun 14, Jul 14, Aug 14},
yticklabels = {54,56,58,60,62,64,66},
x tick label style = {rotate=75, anchor=east}, 
ylabel = Temperature rise on the boiler,
xlabel = time
]
\addplot [mark=x] coordinates {
(1,56)
(2,57)
(3,57)
(4,61)
(5,62)
(6,62)
(7,63)
(8,64)
(9,64)
(10,65)
};
\end{axis}
\end{tikzpicture}
\end{center}
\end{figure}

\end{document}
1
  • 2
    Could you please be a bit more specific and tell us what you mean by "wrong". If you want the axes to extend further, add enlargelimits. If you want bullets instead of crosses, use mark=*. Note also that there exists a dateplot library, which may help you here.
    – user121799
    Sep 17, 2018 at 19:16

2 Answers 2

3
  • If you don't manually overwrite the y axis labels with yticklabels = {...}, you'll get ones that match your data

  • to display the grid, you just have to uncomment grid = major

  • If the axis names should be in the centre, remove axis x line = center and axis y line = center,

  • using a center environment inside a figure will result in additional vertical spacing, use \centering instead.

  • If all data points should have a corresponding x label on the x axis, start counting from 0


\documentclass[a4paper,11pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{siunitx} 
\usepackage{pgfplots}
\usetikzlibrary{intersections, calc}
\pgfplotsset{compat=1.14}
\begin{document}

\begin{figure}[h!]
%\begin{center}
\centering
\begin{tikzpicture}[scale=0.8]
\centering
\begin{axis}[
width= \linewidth,
height = 9cm,
grid = major,
%axis x line = center,
%axis y line = center,
xticklabels = {Oct 13, Nov 13, Dec 13, Jan 2014, Feb 14, Mar 14, Apr 14, May 14, Jun 14, Jul 14, Aug 14},
%yticklabels = {54,56,58,60,62,64,66},
x tick label style = {rotate=75, anchor=east}, 
ylabel = Temperature rise on the boiler,
xlabel = time
]
\addplot [mark=x] coordinates {
(0,56)
(1,57)
(2,57)
(3,61)
(4,62)
(5,62)
(6,63)
(7,64)
(8,64)
(9,65)
};
\end{axis}
\end{tikzpicture}
%\end{center}
\end{figure}

\end{document}

enter image description here

2

Same as @samcarters nice answer but also with a grid and bullets and extended axes and colors.

\documentclass[a4paper,11pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{siunitx} 
\usepackage{pgfplots}
\usetikzlibrary{intersections, calc}
\pgfplotsset{compat=1.14}
\begin{document}

\begin{figure}[h!]
\begin{center}
\begin{tikzpicture}[scale=0.8]
\centering
\begin{axis}[
width= \linewidth,
height = 9cm,
%grid = major,
axis x line = center,
axis y line = center,
xticklabels = {Oct 13, Nov 13, Dec 13, Jan 2014, Feb 14, Mar 14, Apr 14, May 14, Jun 14, Jul 14, Aug 14},
%yticklabels = {54,56,58,60,62,64,66,68},
x tick label style = {rotate=75, anchor=east}, 
y tick label style = {fill=white}, 
ylabel = Temperature rise on the boiler,
ylabel style={rotate=90,anchor=south east,yshift=8mm},
xlabel = time,enlargelimits=0.2,grid=major
]
\addplot [mark=*,blue!40] coordinates {
(1,56)
(2,57)
(3,57)
(4,61)
(5,62)
(6,62)
(7,63)
(8,64)
(9,64)
(10,65)
};
\end{axis}
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}

enter image description here

You must log in to answer this question.

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