[Tex/LaTex] PGFPlots: symbolic x coords + extra ticks

pgfplots

how can i add in this plot the extra x and y ticks ?
enter image description here

\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,
symbolic x coords={%
                  $1$,
                  $2$,
                  $3$,
                  $4$,
                  $5$,
                  $6$,
                  $7$
                  },
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);},
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}

Best Answer

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.

\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}