I followed the conversation at Hide tick numbers in a TikZ/PGF axis environment.. However, the xticklabels=\empty
appears to not cover the exponential part. Here is the code.
\documentclass[12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{figure} \centering
\begin{tikzpicture}
\begin{axis}[
legend columns=-1,
legend style={at={(1,0)},anchor=south east},
width=.8\textwidth,
height=\textwidth,
bar width=8pt,
xmin=0,
xmax=17000,
xbar,
tickwidth = 0pt,
ytick = data,
xticklabels=\empty,
%enlargelimits=auto,
%enlarge y limits = 0.01,
enlarge x limits = 0.02,
symbolic y coords = {Animals, Vegetables, Food products, Minerals, Fuel, Chemicals, Plastic and rubber, Leather, Wood, Textiles},
nodes near coords
]
\addplot coordinates {(863.9,Animals) (3461.3,Vegetables) (913.8,Food products) (527.1,Minerals) (372.1,Fuel) (386.3,Chemicals) (392.7,Plastic and rubber) (860.5,Leather) (90,Wood) (13655.1,Textiles)};
\addplot coordinates {(17.8,Animals) (1457.8,Vegetables) (112.5,Food products) (71.9,Minerals) (2457.2,Fuel) (206.8,Chemicals) (402.2,Plastic and rubber) (51.1,Leather) (35.9,Wood) (1940.6,Texti
les)};
\legend{Exporters, Importers}
\end{axis}
\end{tikzpicture}
\caption{Export across industrial sectors} \label{f:sectors}
\end{figure}
\end{document}
Best Answer
Instead of
xticklabels=\empty
, usextick=\empty
, that removes all ticks, not just the textual labels belonging to the ticks. The scale factor will also disappear. If you're not adding grid lines, I would recommend this.If you are going to add grid lines then you need the ticks, so use
scaled x ticks=false
to just remove the scale factor.Note that with
xticklabels=\empty
, the nodes for those labels are still present, but empty, so they take up space, and effectively add whitespace to the diagram. For example if you havexticklabels=\empty, scaled x ticks=false, xticklabel style={draw}
you can see that the nodes are there:But with
xtick=\empty
the nodes are not there, and there is less whitespace between the caption and the axis box: