3

How can I draw an empty plot, so I can print it and draw the input manually?

I just want the X and Y axes.

I want a time on the X-axis (07:00-22:00) and an Integer (0-10) on the Y-axis, but all I can find on the internet are explanations for diagrams with known values.

| improve this question | | | | |
  • 2
    What have you tried? When you ask a question, please post the code you've tried so that people don't have to start from scratch. Sometimes people are very nice (as in this case) and draw the whole thing from scratch for you, but it is much better if that isn't necessary. Posting some code not only helps helpers, it encourages helpers and it helps to clarify your question, making it more likely that answers will be of real use to you. – cfr Nov 15 '15 at 2:10
  • @cfr Very nice site introduction! – Skeleton Bow Oct 23 '16 at 6:56
8

Here is one option with pgfplots. I had to add some form of plot to make the axis customizations work, so I added one that isn't displayed at all.

enter image description here

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  width=0.8\linewidth,
  axis lines=middle,
  grid,
  ymin=0,
  ymax=11,
  ytick={0,...,10},
  xmin=6,
  xmax=23,
  xtick={7,...,22},
  xticklabel={\pgfmathprintnumber{\tick}:00},
  xticklabel style={rotate=45,anchor=north east}]

\addplot[draw=none] coordinates {(1,1)};
\end{axis}
\end{tikzpicture}
\end{document}

pgfplots also has the possibility of using dates as coordinates, but setting the ticks become a bit more verbose I think, e.g.

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  width=0.8\linewidth,
  grid,
  ymin=0,
  ymax=11,
  ytick={0,...,10},
  date coordinates in=x,
  date ZERO=2015-01-01,
  xmin=2015-01-01 06:00,
  xmax=2015-01-01 23:00,
  xticklabel=\hour:\minute,
  xticklabel style={rotate=45,anchor=north east},
  xtick={
   2015-01-01 07:00,
   2015-01-01 08:30,
   2015-01-01 10:00,
   2015-01-01 11:30,
   2015-01-01 13:00,
   2015-01-01 14:30,
   2015-01-01 16:00,
   2015-01-01 17:30,
   2015-01-01 19:00,
   2015-01-01 20:30,
   2015-01-01 22:00
  }
]
\addplot[draw=none] coordinates {(2015-01-01 12:00,1)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | | | | |
  • Thank you very much, as I understand you just drew a point outsite the plot to make it work, is that right? Can I somehow add those "diagramarrows" at the end of the axis? – bale Nov 15 '15 at 8:51
  • Oh ok, that with the not drawn point is answered by your first sentence (I got confused by "plot"), I'm sorry. – bale Nov 15 '15 at 8:57
  • @bale In the first example the point is actually outside the axis. In the second it is inside, but it's not drawn because of draw=none. As for the arrows, I think axis lines=middle added to the axis options will do what you're after. Will update the first example. – Torbjørn T. Nov 15 '15 at 9:15

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.