Balkendiagramm passt nicht auf A4 Seite

Tabellen und Grafiken erstellen und anordnen


123

Balkendiagramm passt nicht auf A4 Seite

Beitrag von 123 »

Hallo,

vielleicht kann mir jemand behilflich sein..
Ich suche eine Skalierungsmöglichkeit, sodass mein Diagramm auf eine A4-Seite passt und sich die Balken innerhlab des Diagramms nicht überschneiden (so wie es jetzt der Fall ist).

Hier mein Code:
%
\documentclass[11pt]{article}
\usepackage{amsmath,amsfonts}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{geometry}
\geometry{verbose,a4paper,tmargin=25mm,bmargin=25mm,lmargin=15mm,rmargin=20mm}

\begin{document}

\begin{tikzpicture} 
\begin{axis}[
 ybar, 
 width=\textwidth, 
 legend style={at={(0.5,-0.2)}, 
	anchor=north,legend columns=-0.1}, 
 ymin=-0.1,
 ylabel={Personen}, 
 symbolic x coords={1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017}, 
 xtick=data, 
 nodes near coords, 
 	nodes near coords align={vertical}, 
 x tick label style={rotate=45,anchor=east}, 
  ylabel style={inner ysep=0pt},
 ] 

 \addplot coordinates{(1995,2) (1996,0) (1997,0) (1998,2) (1999,0) (2000,1) (2001,0) (2002,0) (2003,3) (2004,1) (2005,2) (2006,0) (2007,1) (2008,6) (2009,26) (2010,2) (2011,0) (2012,2) (2013,4) (2014,1) (2015,2) (2016,0) (2017,1)}; 
 
 \addplot coordinates{(1995,0) (1996,1) (1997,1) (1998,1) (1999,0) (2000,0) (2001,1) (2002,1) (2003,0) (2004,0) (2005,1) (2006,0) (2007,0) (2008,0) (2009,0) (2010,1) (2011,0) (2012,0) (2013,0) (2014,0) (2015,1) (2016,0) (2017,0)};
 
\end{axis} 
\end{tikzpicture}
\end{document}
[\code]

Danke!

Bartman
Forum-Meister
Forum-Meister
Beiträge: 2456
Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz

Beitrag von Bartman »

Benutze beim nächsten Beitrag mit Beispiel bitte [/code] statt [\code].
\documentclass[11pt]{article}
\usepackage{pgfplots}
\usepackage{geometry}

\geometry{verbose,a4paper,tmargin=25mm,bmargin=25mm,lmargin=15mm,rmargin=20mm,showframe}

\pgfplotsset{
   compat=newest,
   /pgf/number format/1000 sep=
}

\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}[
   ymin=0,
   ymax=30,
   ytick={0,2,...,30},
   ybar,
   bar width=5pt,
   width=\textwidth,
   height=.35\textheight,
   legend style={
      at={(0.5,-0.25)},
      anchor=north,
      legend columns=-0.1
   },
   ylabel={Personen},
   xlabel={Jahr},
   xmin=1994,
   xmax=2018,
   xtick=data,
   nodes near coords,
   nodes near coords align={vertical},
   x tick label style={
      rotate=45,
      anchor=east
   }
]
\addplot coordinates{(1995,2) (1996,0) (1997,0) (1998,2) (1999,0) (2000,1) (2001,0) (2002,0) (2003,3) (2004,1) (2005,2) (2006,0) (2007,1) (2008,6) (2009,26) (2010,2) (2011,0) (2012,2) (2013,4) (2014,1) (2015,2) (2016,0) (2017,1)};

\addplot coordinates{(1995,0) (1996,1) (1997,1) (1998,1) (1999,0) (2000,0) (2001,1) (2002,1) (2003,0) (2004,0) (2005,1) (2006,0) (2007,0) (2008,0) (2009,0) (2010,1) (2011,0) (2012,0) (2013,0) (2014,0) (2015,1) (2016,0) (2017,0)};
\legend{Linker Balken,Rechter Balken}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

Rolli
Forum-Guru
Forum-Guru
Beiträge: 382
Registriert: Mi 15. Feb 2017, 08:50
Wohnort: Mittelfranken

Beitrag von Rolli »

Hallo 123,
\begin{tikzpicture} [scale=0.9]
...
verkleinert Dein Bild auf 90%. Die Schriften bleiben unverändert.
\begin{tikzpicture} [scale=0.9, every node/.style={scale=0.9}]
...
verkleinert Dein Bild incl. der Schriften auf 90%.

Hilft Dir das?

Gruß vom Rolli

Antworten