0

I am trying to create a timeline that shows when a policy was implemented in certain states. I am a novice to using tikzpicture. My sample period is 2000 - 2023. With the policy treatment starting in 2003 - 2016 with staggered treament. Is there a way to get the years above the line and the color of the line changed to blue during the staggered policy treatment?

The code I have generated places everything below the line.

\begin{frame}
\begin{figure}
\begin{tikzpicture}[x=1.5cm,nodes={text width=1.0cm,align=left}]
\draw[black,->,thick,>=latex,line cap=rect]
  (0,0) -- (10,0);
\foreach \Text [count=\Xc starting from 0] in 
{{2000.},%
 {2001.},%
 {2002.},%
 {2003. Louisiana. Vermont. Arkansas.},%
 {2004. Nebraska.},
 {2006. Ohio},
 {2007. New Hampshire.},
 {2008. Michigan.},
 {2010. New York.},
 {2012. Florida.},
 {2015. New Mexico.},
 {2016. Colorado.},
 {2018.},
 {2019.},
 {2021.}}  
{\fill (\Xc,0) circle[radius=1.5pt];
\node[below=0.2ex] at (\Xc,0) {\Text};}  
\end{tikzpicture}
\end{figure}
\end{frame}

1 Answer 1

2

You could split your list into a component for the year and one for the text:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
    
\begin{frame}
\begin{figure}
\begin{tikzpicture}[x=1.5cm,nodes={text width=1.0cm,align=left},scale=0.45,transform shape]
\draw[black,->,thick,>=latex,line cap=rect]
  (0,0) -- (15,0);
\draw[blue,ultra thick,>=latex,line cap=rect]
  (3,0) -- (11,0);
\foreach \yr/\Text [count=\Xc starting from 0] in 
{{2000/},%
 {2001/},%
 {2002/},%
 {2003/Louisiana Vermont Arkansas},%
 {2004/Nebraska},
 {2006/Ohio},
 {2007/New Hampshire},
 {2008/Michigan},
 {2010/New York},
 {2012/Florida},
 {2015/New Mexico},
 {2016/Colorado},
 {2018/},
 {2019/},
 {2021/}}  
{
\fill (\Xc,0) circle[radius=1.5pt];
\node[above=0.2ex] at (\Xc,0) {\yr};
\node[below=0.2ex,text width=1cm,align=center] at (\Xc,0) {\Text};
}  
\end{tikzpicture}
\end{figure}
\end{frame}

    
\end{document}

enter image description here

3
  • Thank you. is there a way to make the font smaller? Mar 23 at 2:24
  • 2
    Even more 😉? That way no one will be able to read it. You could think a different strategy, like use 2-letters code for the states... Anyway, font=\scriptstyle in the node options should work, but...
    – Rmano
    Mar 23 at 7:59
  • @econ_grad12345 You're welcome! For the font, I second @ Rmano's comment. I already had to scale down your code to only 45% to even fit it on a frame. Maybe rotate the labels to be diagonal to get more room, but I would not make them smaller, they are already much too small for a presentation. Mar 23 at 8:57

You must log in to answer this question.

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