You shouldn't use symbolic coordinates just to change the alignment. Symbolic coordinates are quite unflexible. You can get the same alignment by simply setting x tick label as interval
with normal numerical coordinates.
![](https://i.stack.imgur.com/AitD9.png)
\documentclass[border=0.5mm,12pt]{standalone}
\usepackage{pgfplots,pgfplotstable} % Grafici
\pgfplotsset{%
mesh line legend/.style={legend image code/.code=\meshlinelegend#1},%
/pgf/number format/use comma,%
compat=newest,%
% height=9cm,%
width=12cm%
}
\begin{document}
%\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[%
ybar,
/pgf/number format/fixed,
xtick=data,
tick style={thin,black},
ymin=0, ymax=12,
point meta min={0},
minor ytick={0,0.4,...,12},
point meta max={12},
yticklabel shift=2pt,
xticklabel shift=2pt,
xlabel=\large {Classe},
ylabel=\large {Frequenza},
ymajorgrids=true,
%xticklabel interval boundaries,
colorbar,
colorbar style={
/pgf/number format/fixed,
xticklabel shift=2pt,
xticklabel style={text height=1.5ex}
},
axis line style={draw=none}, after end axis/.append code={\draw (rel axis cs:0,0) rectangle (rel axis cs:1,1);},
x tick label as interval,
extra x ticks=3,
extra x tick labels=3.5,
extra x tick style={
red,
x tick label as interval=false
},
colormap={new}{color(0cm)=(violet);color(1cm)=(blue);color(2cm)=(cyan);color(3cm)=(green);color(4cm)=(yellow);color(5cm)=(orange);color(6cm)=(red)}
]
\addplot[%
ybar interval,
draw=black
] coordinates{%
(1, 6)
(2, 9)
(3, 11)
(4, 12)
(5, 7)
(6, 5)
(7, 0)
};
\end{axis}
%\end{figure}
\end{tikzpicture}
\end{document}
You can use
y filter/.expression={y==0 ? nan : y}
in the options of \addplot
.
\documentclass{article}
% ---------------------------------- tikz
\usepackage{pgfplots} % to print charts
\pgfplotsset{compat=1.12}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis} [
% general
ybar,
scale only axis,
height=0.5\textwidth,
width=1.2\textwidth,
ylabel={\# Dots},
nodes near coords,
xlabel={Variation},
xticklabel style={
rotate=90,
anchor=east,
},
%enlarge x limits={abs value={3}},
]
\addplot+[y filter/.expression={y==0 ? nan : y}] table [
x=grade,
y=value,
] {
grade value
-11 0
-10 0
-9 0
-8 0
-7 0
-6 0
-5 3
-4 1
-3 2
-2 15
-1 11
0 179
1 8
2 1
3 0
4 1
5 2
6 0
7 0
8 0
9 0
10 0
11 0
};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
![enter image description here](https://i.stack.imgur.com/oNraE.png)
Best Answer
Starting from PGFPlots version 1.9, asymmetric error bars are directly supported: