Unterschiedliche Farben im Säulendiagramm

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: Unterschiedliche Farben im Säulendiagramm

von esdd » Sa 4. Jul 2015, 07:49

Wenn jede Säule eine andere Farbe haben soll, dann musst Du jede Säule einzeln plotten. Da bei mehreren ybar Plots in einer axis Umgebung die Balken mit unterschiedlichen Verschiebungen um die x-Werte eingetragen werden, musst Du dann entweder bis auf beim letzten Plot überall forget plot mit angeben und dafür dann wieder die Farbe manuell wählen. Oder Du legst mehrere axis Umgebungen übereinander, aber auch da muss die Farbe dann einzeln festgelegt werden. Wozu brauchst Du die Farben überhaupt? Sie scheinen doch keine zusätzliche Info zu enthalten.

Warum Du an jeden Balken den y-Wert nochmal von Hand schreibst, verstehe ich auch nicht. Du verwendest doch schon nodes near coords?

Gruß
Elke

PS: Wie die anderen schon gesagt haben, Dein Beispiel ist nicht lauffähig.

von Besserwisser » Fr 3. Jul 2015, 22:36

sashavaia hat geschrieben:js es wird ein PDF erzeugt, sie sind aber einfarbig...
Seltsam, bei mir ergibt das ja nur
Running `LaTeX' on `test' with ``pdflatex --synctex=1 -interaction=nonstopmode "\input" test.tex''
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2015/01/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(./test.tex

! LaTeX Error: Environment figure undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.1 \begin{figure}
                  [h]

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.1 \begin{figure}[
                   h]

! LaTeX Error: Environment tikzpicture undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.3 \begin{tikzpicture}
                       

! LaTeX Error: Environment axis undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.4 \begin{axis}
                [
! Undefined control sequence.
l.21 \node
          [coordinate,pin=right :{454.8}] at (axis cs:Cina,454.8) {};
! Undefined control sequence.
l.22 \node
          [coordinate,pin=above :{203.5}] at (axis cs:USA,203.5) {};
! Undefined control sequence.
l.23 \node
          [coordinate,pin=above :{107.5}] at (axis cs:Brasile,107.5) {};
! Undefined control sequence.
l.24 \node
          [coordinate,pin=above :{97.4}] at (axis cs:Germania,97.4) {};
! Undefined control sequence.
l.25 \node
          [coordinate,pin=above :{89.5}] at (axis cs:Canada,89.5) {};
! Undefined control sequence.
l.26 \node
          [coordinate,pin=above :{79.6}] at (axis cs:Giappone,79.6) {};
! Undefined control sequence.
l.27 \node
          [coordinate,pin=above :{75.3}] at (axis cs:India,75.3) {};
! Undefined control sequence.
l.28 \node
          [coordinate,pin=above :{54.0}] at (axis cs:Italia,54.0) {};
! Undefined control sequence.
l.29 \node
          [coordinate,pin=above :{51.3}] at (axis cs:Russia,51.3) {};
! Undefined control sequence.
l.30 \node
          [coordinate,pin=above :{50.2}] at (axis cs:Spagna,50.2) {};
! Undefined control sequence.
l.31 \addplot
             +[ybar] plot coordinates {(Cina,454.8) (USA,203.5)

Overfull \hbox (20.0pt too wide) in paragraph at lines 1--33
 [] 
! Undefined control sequence.
l.34 \legend
            {cumulato}

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.34 \legend{c
              umulato}

! LaTeX Error: \begin{document} ended by \end{axis}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.35 \end{axis}
               

! LaTeX Error: \begin{document} ended by \end{tikzpicture}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.36 \end{tikzpicture}
                      

! LaTeX Error: \caption outside float.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.37 \caption
             {Top 10 Paesi nel 2014 per capacità cumulata}

! LaTeX Error: \begin{document} ended by \end{figure}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.39 \end{figure}
                 
)
! Emergency stop.
<*> \input test.tex
                   
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on test.log.

LaTeX exited abnormally with code 1 at Fri Jul  3 22:32:53
Ehrlich gesagt, glaube ich nicht, dass das bei dir anders ist. Du solltest vielleicht den Link, den dir Bartman gegeben hat, mal genauer in Augenschein nehmen …

von sashavaia » Fr 3. Jul 2015, 21:38

js es wird ein PDF erzeugt, sie sind aber einfarbig...

von Bartman » Fr 3. Jul 2015, 19:15

Dieser Quelltext erzeugt bei Dir eine PDF-Datei?

Unterschiedliche Farben im Säulendiagramm

von sashavaia » Fr 3. Jul 2015, 17:59

Hallo zusammen,

ich wuerde gerne ein Säulendiagramm erstellen.
Ich habe den unten stehenden Code benutzt:
\begin{figure}[h]
	\centering
 	\begin{tikzpicture}
	\begin{axis}[
	axis lines=left,
    ybar stacked,       
    enlargelimits=0.1,
    nodes near coords,
	%nodes near coords align={horizontal},
    legend style={at={(1.4,-0.50)},
      anchor=north,legend columns=-1},
    ylabel={GW},
    symbolic x coords={Cina, USA, Brasile, Germania, 
		Canada, Giappone, India, Italia, Russia, Spagna},
    xtick=data,
      x tick label style={rotate=48,anchor=east},
    width=13cm,
    height=8cm,
    legend style={cells={anchor=west},legend pos=north east}
    ]
    \node[coordinate,pin=right :{454.8}] at (axis cs:Cina,454.8) {};
     \node[coordinate,pin=above :{203.5}] at (axis cs:USA,203.5) {};
      \node[coordinate,pin=above :{107.5}] at (axis cs:Brasile,107.5) {};
       \node[coordinate,pin=above :{97.4}] at (axis cs:Germania,97.4) {};
        \node[coordinate,pin=above :{89.5}] at (axis cs:Canada,89.5) {};
         \node[coordinate,pin=above :{79.6}] at (axis cs:Giappone,79.6) {};
          \node[coordinate,pin=above :{75.3}] at (axis cs:India,75.3) {};
           \node[coordinate,pin=above :{54.0}] at (axis cs:Italia,54.0) {};
            \node[coordinate,pin=above :{51.3}] at (axis cs:Russia,51.3) {};
             \node[coordinate,pin=above :{50.2}] at (axis cs:Spagna,50.2) {};
\addplot+[ybar] plot coordinates {(Cina,454.8) (USA,203.5) 
  (Brasile,107.5) (Germania,97.4) (Canada,89.5) (Giappone,79.6) (India,75.3) (Italia,54.0) (Russia,51.3) (Spagna,50.2)};

\legend{cumulato}
\end{axis}
\end{tikzpicture}
\caption{Top 10 Paesi nel 2014 per capacità cumulata}
\label{fig: capacità2014}
\end{figure}
Mein Problem ist, dass ich gerne bei jede Säule eine andere Farbe anzeigen lassen will, aber hier die gleiche Farbe haben.
Hat jemand einen Loesungsvorschlag?

Vielen Dank.[/code]

Nach oben