I'm doing a histogram with a large number of bins:
\pgfplotstableset{col sep=semicolon}
\begin{tikzpicture}
\begin{axis}[
ybar interval,
]
\addplot+[hist={bins=200}] table[y index=0] {FILENAME};
\end{axis}
\end{tikzpicture}
Unfortunately, pgfplots produces a terribly ugly x-axis where the xticks are printed too close together so that they are overlapping and you can't read a thing.
How can I reduce the number of ticks? For example show only every nth tick.
Best Answer
For a histogram with such a large number of bins,
ybar interval
as anaxis
option is not the ideal choice.ybar interval
, if passed to the axis, will place a label for each bin, and draw a vertical line between each pair of bins; the algorithm usually employed for finding a useful number of labels is not used here. In your case, simply omittingybar interval
(or supplyingybar
instead) in the axis options yields a much better result. Note that theybar interval
style is set for the individual plot anyway because you're usinghist
, but as a plot option, it doesn't influence the label placement:The plot could be improved a bit by adding vertical grid lines, and choosing
hist/data min
,hist/data max
, andhist/bins
in such a way that the bins line up with the grid lines: