How to get my graph draw larger?
You can adjust it in the options for standalone
, by changing the first line of your code to:
\documentclass[tikz,border={0 0 5pt 0}]{standalone}
Just as of topic supplement to Jānis Lazovskis answer with small changes of your code and his image border proposition. Changes are indicated in code by % <---
.
Edit: table mydata is moved inside
tikzpicture` and a little bit changed
\documentclass[margin=1pt]{standalone} % <---
\usepackage{pgfplots}
\pgfplotsset{compat=1.16} % <---
\begin{document}
\begin{tikzpicture}
\pgfplotstableread{
interval carT carD
1 1.2 0.1
2 12.8 3.8
3 15.5 10.4
4 14.0 17.3
5 7.9 21.1
6 3.0 22.3
7 3.0 22.3
8 3.0 22.3
9 3.0 22.3
10 3.0 22.3
}\mydata
\begin{axis}[
width=\linewidth,
height=.8\linewidth,
ybar=0.5mm, % <--- distance between bars (shift bar)
bar width=4.4mm, % <--- width of bars
legend style={legend columns=-1,
outer sep=1mm, % <---
font=\scriptsize, % <---
anchor=north,
at={(0.5,1)},
},
nodes near coords,
nodes near coords style={font=\scriptsize, inner sep=2pt}, % <---
nodes near coords align={vertical},
ylabel={\%},
ymin=0, ymax=30, % <---
xtick=data,
scale only axis, % <---
]
\addplot table[x=interval,y=carT]{\mydata};
\addplot table[x=interval,y=carD]{\mydata};
\legend{Trips, Distance}
\end{axis}
\end{tikzpicture}
\end{document}