Graphics, Figures & TablesBar Plot with logarithmic Scale

Information and discussion about graphics, figures & tables in LaTeX documents.
feuersaenger
Posts: 34
Joined: Sun Oct 16, 2011 5:56 pm

Bar Plot with logarithmic Scale

Post by feuersaenger »

Hi elect,

If I am not mistaken, the space reserved for the second data point comes from the grouping: pgfplots assumes that your two \addplot commands should be grouped together: every plot allocates some position for every processor (y tick).

If you omit this grouping, I see the following alternatives:
  1. accept that some bars overlap each other (might be interesting if you choose different arguments for bar width)
  2. determine shifts manually such that bars do not overlap (possible by adjusting 'bar shift').
  3. use stacked plots.
Note that you can also reduce the size for your plot by specifying width, height, and perhaps enlargelimits as in

Code: Select all

\begin{tikzpicture}
\begin{semilogxaxis}[
height=4cm,
width=10cm,
xbar,
symbolic y coords={AMD Phenom II X4 955 3.2GHz,GeForce GTX 285 },
ytick=data,
enlargelimits=0.7,
]
\addplot+[bar shift=0pt] coordinates {(7,AMD Phenom II X4 955 3.2GHz)  (9,GeForce GTX 285) };
\addplot+[bar shift=12pt] coordinates {(8,AMD Phenom II X4 955 3.2GHz) };
\end{semilogxaxis}
\end{tikzpicture}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

feuersaenger
Posts: 34
Joined: Sun Oct 16, 2011 5:56 pm

Bar Plot with logarithmic Scale

Post by feuersaenger »

Hi elect,

since you chose to post this BIP bar chart as example of what you'd like to achieve, I took the freedom to re-generate this chart by means of pgfplots.

Feel free to adapt it to your needs (including log scaling):

Code: Select all

\documentclass{minimal}
\usepackage[utf8]{inputenc}


\usepackage{tikz,pgfplots}

\pgfplotsset{compat=1.3}

\begin{document}


\begin{tikzpicture}
\begin{axis}[
	width=15cm,
	height=6cm,
	symbolic x coords={Rumaenien,Griechenland,Spanien,Polen,Grossbritannien,Niederlande,Frankreich, Deutschland},
	xticklabel style={anchor=east,rotate=45},
	ybar, 
	axis x line*=bottom,
	axis y line*=left,
	title={Wachstumsrate des realen BIP für die zehn...},
	ylabel={\%},
	every axis y label/.style={at={(0,1)},anchor=east,xshift=-3pt},
	xtick=data,
	bar width=20pt,
	ymajorgrids,
	ytick align=outside,
	nodes near coords,
	ymin=0,
	x axis line style={yshift=-3pt},
	y axis line style={xshift=-3pt},
]
	\addplot
	table
	{
	Land BIP
	Rumaenien 4.1
	Griechenland 3.7
	Spanien 3.5
	Polen 3.5
	Grossbritannien 1.9
	Niederlande 1.5
	Frankreich 1.2
	Deutschland 0.9
	};
\end{axis}
\end{tikzpicture}
\end{document}
The keys should be available in the reference manual. There is just one limitation: the 'symbolic x coords' does not allow unicode chars. In order to include unicode chars, you need to provide xticklabels={<list>}. In this context, <list> can contain unicode chars.

Best regards

Christian
Attachments
PP.pdf
(27.37 KiB) Downloaded 298 times
Post Reply