1

Is there any way to squeeze the bars closer together in this plot? There seems to be a lot of unused space between them.

\begin{tikzpicture}[]

\begin{axis}[
xmin=0,xmax=80,height = 3in,  width=10in, bar width=1mm,
% x=2.5mm,  xbar=0.1pt, these don't seem to have an effect here    
ytick = {0,1,...,4},yticklabels={clear,tint,red,dark,dark red},    
xtick = {1,3,...,71}, xticklabels =     
{24,25,26,27,28,29,30,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,24,25,26,27,28,29}]


\addplot+[ ybar,mark=0,fill=pink,draw=none] coordinates {

(
(1,3)(2,3)(3,1)(4,4)(5,3)(6,4)(7,3)(8,2)(9,3)
(10,2)(11,1)(12,3)(13,3)(14,2)(15,1)(16,2)(17,3)
(18,4)(19,3)(20,2)(21,4)(22,3)(23,1)(24,4)(25,1)
(26,4)(27,3)(28,4)(29,3)(30,3)(31,3)(32,4)(33,1)
(34,2)(35,0)(36,1)(37,1)(38,4)(39,1)(40,4)(41,3)
(42,4)(43,3)(44,4)(45,3)(46,3)(47,1)(48,1)(49,0)
(50,1)(51,0)(52,1)(53,3)(54,1)(55,1)(56,3)(57,1)
(58,4)(59,1)(60,1)(61,3)(62,2)(63,0)(64,1)(65,0)
(66,1)(67,0)(68,2)(69,1)(70,1)(71,2)

};

\end{axis}

\end{tikzpicture}

1 Answer 1

2

Well, you have 1mm wide bars in a 10in wide plot, so they can only take up so much space. Reducing the width of the axis and/or increasing the width of the bars would fill up more space. Below I also reduced xmax and reduced the fontsize of the ticklabels on the x-axis, so they're not as close together.

enter image description here

\documentclass[border=3mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=72,height = 3in,  width=6in, bar width=1.5mm,
ytick = {0,1,...,4},yticklabels={clear,tint,red,dark,dark red},
xtick = {1,3,...,71}, xticklabels = 
{24,25,26,27,28,29,30,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,24,25,26,27,28,29},
xticklabel style={font=\footnotesize}]


\addplot+[ ybar,mark=0,fill=pink,draw=none] coordinates {
(1,3)(2,3)(3,1)(4,4)(5,3)(6,4)(7,3)(8,2)(9,3)
(10,2)(11,1)(12,3)(13,3)(14,2)(15,1)(16,2)(17,3)
(18,4)(19,3)(20,2)(21,4)(22,3)(23,1)(24,4)(25,1)
(26,4)(27,3)(28,4)(29,3)(30,3)(31,3)(32,4)(33,1)
(34,2)(35,0)(36,1)(37,1)(38,4)(39,1)(40,4)(41,3)
(42,4)(43,3)(44,4)(45,3)(46,3)(47,1)(48,1)(49,0)
(50,1)(51,0)(52,1)(53,3)(54,1)(55,1)(56,3)(57,1)
(58,4)(59,1)(60,1)(61,3)(62,2)(63,0)(64,1)(65,0)
(66,1)(67,0)(68,2)(69,1)(70,1)(71,2)
};

\end{axis}

\end{tikzpicture}
\end{document}
0

You must log in to answer this question.

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