Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can convert the filling of the bars from horizontal to vertical ?

\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}
\makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother
\pgfplotsset{axis line on top/.style={
 axis on top=false,
 after end axis/.append code={
    \pgfplotsset{axis line style=opaque,
      ticklabel style=opaque,
      tick style=opaque,
      grid=none}
    \pgfplotsdrawaxis}
  }
}
\pgfdeclarehorizontalshading{stefan}{50bp}{
color(0.00000000000000bp)=(violet);
color(8.33333333333333bp)=(blue);
color(16.66666666666670bp)=(cyan);
color(25.00000000000000bp)=(green);
color(33.33333333333330bp)=(yellow);
color(41.66666666666670bp)=(orange);
color(50.00000000000000bp)=(red)
}
\begin{axis}[%
ybar,
xtick=data,
/pgf/number format/fixed,
legend pos=outer north east,
ymajorgrids=true,
%xmin=0, xmax=7,
ymin=0, ymax=14,
point meta min={0},
point meta max={14},
yticklabel shift=2pt,
xticklabel shift=2pt,
x tick label as interval,
minor ytick={0,0.4,...,14},
xticklabel style={text height=1.5ex},
xtick={0,1,...,7},
extra x ticks={0,1,...,7},
extra x tick style={
    xticklabel pos=right,
    xticklabel style={text depth=0pt}
},
%extra y ticks={0,2,...,12},
%extra y tick style={
%    yticklabel pos=right
%},
tick style={thin,black},
xlabel=\large Classe,
ylabel=\large Frequenza,
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,
        area style,
        shading=stefan,
%        draw=none,
        shader=interp,
        samples=10,
        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}
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

THANKS JAKE

I'm sorry but I hadn't noticed !

\pgfdeclareverticalshading change this !

\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}
\makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother
\pgfplotsset{axis line on top/.style={
 axis on top=false,
 after end axis/.append code={
    \pgfplotsset{axis line style=opaque,
      ticklabel style=opaque,
      tick style=opaque,
      grid=none}
    \pgfplotsdrawaxis}
  }
}
\pgfdeclareverticalshading{stefan}{50bp}{
color(0.00000000000000bp)=(violet);
color(8.33333333333333bp)=(blue);
color(16.66666666666670bp)=(cyan);
color(25.00000000000000bp)=(green);
color(33.33333333333330bp)=(yellow);
color(41.66666666666670bp)=(orange);
color(50.00000000000000bp)=(red)
}
\begin{axis}[%
ybar,
xtick=data,
/pgf/number format/fixed,
legend pos=outer north east,
ymajorgrids=true,
%xmin=0, xmax=7,
ymin=0, ymax=14,
point meta min={0},
point meta max={14},
yticklabel shift=2pt,
xticklabel shift=2pt,
x tick label as interval,
minor ytick={0,0.4,...,14},
xticklabel style={text height=1.5ex},
xtick={0,1,...,7},
extra x ticks={0,1,...,7},
extra x tick style={
    xticklabel pos=right,
    xticklabel style={text depth=0pt}
},
%extra y ticks={0,2,...,12},
%extra y tick style={
%    yticklabel pos=right
%},
tick style={thin,black},
xlabel=\large Classe,
ylabel=\large Frequenza,
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,
        area style,
        shading=stefan,
%        draw=none,
        shader=interp,
        samples=10,
        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}
share|improve this answer
1  
Hehe, no problem! –  Jake Jun 11 '12 at 21:30
1  
You are the undisputed king in the Pgfplots field !! –  FormlessCloud Jun 11 '12 at 21:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.