3

I have one document with 2 documents included. In the first document I have a pgfPlot with \pgfplotsset{ ybar stacked, ...etc } and in the second one \pgfplotsset{ ybar, ..etc }, but the first pgfplotsset goes in conflict with the second, and also the second document has "ybar stacked" option active.

Here the documents:

Main:

 \begin{document}

\include{chapter1}
\include{chapter2}

\end{document}

chapter1

    \pgfplotsset{
ybar stacked, 
enlargelimits =0.05,
legend style ={at={(0.5,-0.5)},
anchor=north,
legend columns=-1},
ylabel={Ore},
xtick=data,
x tick label style={rotate=45,anchor=east},
symbolic x coords={Enrico Rotundo,Federico Poli,Giacomo Fornari,Gianluca Donato,Luca De Franceschi,Nicolò Tresoldi,Serena Girardi}
}

\begin{figure}[H]
\begin{tikzpicture}
\begin{axis}
\input{columnChart_rr}
\legend{amministratore, analista, progettista, programmatore, responsabile, verificatore}
\end{axis}
\end{tikzpicture}
\caption{Ore per componente, periodo di analisi}
\end{figure}

chapter2

\pgfplotsset{
ybar, 
enlargelimits =0.10,
legend style ={at={(0.5,-0.5)},
anchor=north,
legend columns=-1},
ylabel={Ore},
xtick=data,
x tick label style={rotate=45,anchor=east},
symbolic x coords={Amministratore, Analista, Progettista, Programmatore, Responsabile, Verificatore},
}


    \begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}
\input{columnChart_consuntivo_rr}
\legend{preventivate,consumate}
\end{axis}
\end{tikzpicture}
\caption{Differenza preventivo consuntivo per ruolo, periodo di analisi}
\end{figure}

The problem is that chapter2 use ybar stacked option which is in chapter1 file.

3

You can deactivate the stacking by setting stack plots=false:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9, samples=5}

\begin{document}

\pgfplotsset{ybar stacked}
\begin{tikzpicture}
\begin{axis}
\addplot {rnd};
\addplot {rnd};
\end{axis}
\end{tikzpicture}

\pgfplotsset{ybar, stack plots=false}
\begin{tikzpicture}
\begin{axis}
\addplot {rnd};
\addplot {rnd};
\end{axis}
\end{tikzpicture}
\end{document}

Alternatively, you can keep the ybar stacked option local by supplying it to the axis environment directly, instead of setting it globally using \pgfplotsset:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9, samples=5}

\begin{document}

\begin{tikzpicture}
\begin{axis}[ybar stacked]
\addplot {rnd};
\addplot {rnd};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[ybar]
\addplot {rnd};
\addplot {rnd};
\end{axis}
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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