The histogram bars span the ranges 0 to 1, 1 to 2, 2 to 3, etc., so they are centered on 0.5, 1.5, 2.5, etc. The bar plot bars are centered at 0, 1, 2, etc. To align the two plots, you have to shift one of them. In this case, because you only have integer values, I think it makes sense to let the histogram bins run from -0.5
to 0.5
, 0.5
to 1.5
, etc. You can do that by setting data min=-0.5, data max=10.5
.
To make the histogram semi-transparent, you can set opacity=0.5
.
To make the bars of the bar plot each one unit wide, you can set bar width=1
(this requires PGFPlots version 1.8 or higher).
![](https://i.stack.imgur.com/JVQhy.png)
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{ compat=1.9}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar]
\addplot +[bar width=1] table {
0 6.960737e+00
1 2.991752e+01
2 6.429334e+01
3 9.211177e+01
4 9.897500e+01
5 8.507968e+01
6 6.094597e+01
7 3.742117e+01
8 2.010471e+01
9 9.601201e+00
10 4.126634e+00
11 1.612403e+00
};
\addplot+[hist={data=x,bins=11,data max=10.5,data min=-0.5}, opacity=0.5]
table [y expr=1] {
4
6
6
5
6
6
4
2
6
5
6
6
4
5
3
5
2
3
4
5
6
6
7
7
3
5
1
2
1
4
2
6
6
9
1
5
0
7
3
8
2
4
6
4
4
5
5
7
6
6
4
2
4
3
4
2
2
4
0
2
6
4
4
5
5
5
5
4
1
6
5
10
6
1
4
4
2
5
6
5
6
3
3
5
3
3
0
7
7
4
4
3
3
7
7
6
0
5
4
4
6
3
4
8
3
4
1
3
2
3
4
4
6
4
2
4
4
1
5
4
8
4
6
7
3
3
1
7
4
4
1
6
5
7
4
5
2
4
0
6
3
2
2
4
3
5
4
4
2
5
5
3
3
7
3
3
5
3
6
4
0
4
2
1
4
1
5
6
6
7
4
4
3
6
8
3
2
5
5
6
6
2
5
5
7
3
1
4
4
3
3
2
5
5
4
4
4
3
6
5
6
3
7
5
6
4
4
6
3
4
4
4
5
2
3
4
5
6
5
4
5
10
4
5
8
1
6
3
5
2
3
1
5
3
5
2
4
1
2
0
3
2
7
7
3
4
2
9
3
1
8
5
4
2
4
5
3
3
4
5
2
2
3
3
2
3
4
8
4
5
3
2
8
1
2
6
4
6
7
4
4
4
1
5
5
3
4
4
3
5
7
6
3
6
6
4
7
5
5
2
10
7
0
3
1
3
7
7
2
5
4
3
2
5
6
6
3
5
3
2
3
1
4
7
6
7
7
5
5
4
3
3
6
3
9
4
3
3
6
7
6
8
7
2
4
8
6
6
3
4
6
5
4
6
5
6
5
2
1
2
4
4
7
2
4
3
4
4
4
3
3
3
3
2
3
6
11
5
2
4
6
6
3
3
5
4
5
3
4
4
4
5
5
8
3
5
2
3
6
4
8
2
3
5
6
5
6
5
1
6
5
2
2
6
6
6
6
8
2
6
6
6
7
4
3
3
1
6
3
5
2
1
5
3
3
3
2
3
5
4
3
7
9
4
5
9
4
5
3
5
5
3
0
6
2
5
4
3
8
7
3
7
3
6
5
4
6
5
6
1
5
2
7
5
7
7
4
3
4
4
3
4
3
5
4
6
4
6
4
4
2
1
4
5
6
4
4
3
6
5
8
7
4
6
4
3
2
4
7
4
};
\end{axis}
\end{tikzpicture}
\end{document}
\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-network}
\begin{filecontents}{vertices.csv}
id, x, y ,label
0, -1.25, 4.5, C
1, 3.5, 4.5, C++
2, 3.5, 2.5, HTML
3, -2.75, 2.5, JavaScript
4, 1.25, 5, Python
5, 1.25, 1.75, CSS
6, 3.75, 6, Shell
7, -2.25, 5.75, Objective-C
8, 1.75, -0.5, PHP
9, 5, 0, Java
10, 5.25, 3.5, Makefile
11, -1.75, 0, Ruby
\end{filecontents}
\begin{filecontents}{edges.csv}
u, v, lw
0, 3, 1
0, 2, 2
2, 1, 1
3, 1, 5
11, 5, 1
11, 3, 10
11, 0, 1
8, 0, 1
7, 0, 1
4, 5, 8
0, 4, 1
4, 1, 1
6, 10, 1
10, 9, 3
9, 2, 1
2, 10, 1
8, 5, 1
8, 2, 1
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\Vertices[size=0, style={inner sep=0pt}]{vertices.csv}
\Edges[color=lightgray]{edges.csv}
\end{tikzpicture}
\end{document}
![Network graph with labels and edges](https://i.stack.imgur.com/XhHwX.png)
Best Answer
As the PostScript language has a
floor
function, it's easy withpst-plot
: