Graphics, Figures & TablesChange base of pgfplot axis?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
teer
Posts: 2
Joined: Sat Sep 19, 2020 11:15 pm

Change base of pgfplot axis?

Post by teer »

So I have a vertical timeline. It records events over 24h, to the nearest minute, with one day per page.

But a day has 1440 minutes, not 2400. So setting the interval between 00:00 and 24:00, with a (wrongly) implied scale of 100 per hour.

Is there a way to change this?

Code: Select all

\documentclass[english]{book}

\usepackage{charter}
\usepackage{pgfplotstable}

\newcommand{\vtimeline}{%
	\begin{tikzpicture}
		\begin{axis}[
			y post scale=-1,
			footnotesize,
			hide x axis,
			axis y line=left,
			axis line style={-, draw=none},
			ytick=data,
			xmin=0.99,
			clip=false,
			nodes near coords,
			nodes near coords align=right,
			point meta=explicit symbolic,
			yticklabel style={
				/pgf/number format/set thousands separator={},
				inner sep=1pt
			},
			scale only axis,
			width=1mm,
			height=23cm,
			tick align=outside,
			every tick/.append style={thin, cyan}
			]
			
			\addplot [mark=*,cyan,mark size=2, shorten <=-2mm, shorten >=-2mm, thick] table[y index=0, x expr=1, meta=label] {\datatable};
			
		\end{axis}
	\end{tikzpicture}
}

%%% FIELDS %%%
% not the real title, but now I wish it was
\title{Hello World: Does A Computer Programmed to be Polite Actually Have Good Manners?}
\author{Anony. E. Mouse}
\date{}


\begin{document}
	\frontmatter
	
	\maketitle
	
	\tableofcontents
	\setcounter{page}{0}
	
	\mainmatter
	
	\pgfplotstableread[col sep=semicolon]{
		start ; end	; label
		0000 ; 0000	; 
		0800 ; 0800	; Foo
		0800 ; 0822	; Bar
		0826 ; 0826	; Event1
		0826 ; 0857	; Event2
		0857 ; 0857	; Event3
		0900 ; 0934	; Event4
		0935 ; 0957	; Event5
		0957 ; 1100	; Event6
		1100 ; 1239	; Event7
		1239 ; 1315	; Event8
		1315 ; 1411	; Event9
		1411 ; 1641	; Abc
		1641 ; 1655	; Xyz
		1655 ; 1708	; Last entry
		2400 ; 2400	; 
	}\datatable
	\vtimeline
	
	\backmatter
	
\end{document}
These would be slightly further apart at base 60, no?
Image

PS. Sorry in advance for making two threads this week. I'm getting into tables and pgf/tikz and to be honest it is quite daunting. Thank you very much to anyone who can help me gain any insight.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply