Graphics, Figures & Tables ⇒ Bar Plot with logarithmic Scale
Bar Plot with logarithmic Scale
So, is it possible to have a bar plot with a logarithmic scale?
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
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Bar Plot with logarithmic Scale
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Bar Plot with logarithmic Scale
localghost wrote:Show your recent efforts by a minimal example. Emphasize on "minimal".
Best regards and welcome to the board
Thorsten
Sure, sorry
Like this, but instead 0-4 -> 1 -10 - 100 - 1000
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Bar Plot with logarithmic Scale
For the present I suggest to take a look at packages like pgfplots (based on pgf/tikZ) or pst-plot (based on PSTricks).
[1] View topic: Avoidable mistakes
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Bar Plot with logarithmic Scale
I know what you mean, and I did, but very quickly, because if you take care to my post, my goal is to know whether it is possible having bar plot and logarithmic axeslocalghost wrote:You obviously didn't follow the link in my last reply.
Btw, I think this is what you meant:
Code: Select all
\definecolor{myblue}{HTML}{92dcec}
\begin{tikzpicture}
\draw (0cm,0cm) -- (15.5cm,0cm); %Abzisse
\draw (0cm,0cm) -- (0cm,-0.1cm); %linkes Ende der Abzisse
\draw (15.5cm,0cm) -- (15.5cm,-0.1cm); %rechtes Ende der Abzisse
\draw (-0.1cm,0cm) -- (-0.1cm,4.5cm); %Ordinate
\draw (-0.1cm,0cm) -- (-0.2cm,0cm); %unteres Ende der Ordinate
\draw (-0.1cm,4.5cm) -- (-0.2cm,4.5cm) node [left] {\%}; %oberes Ende der Ordinate
\foreach \x in {1,...,4} %Hilfslinien
\draw[gray!50, text=black] (-0.2 cm,\x cm) -- (15.5 cm,\x cm)
node at (-0.5 cm,\x cm) {\x}; %Beschriftung der Hilfslinien
\node at (7.5cm,5cm) {Wachstumsrate des realen BIP für die zehn
Bevölkerungsreichsten Staaten der EU 2005}; %Überschrift
\foreach \x/\y/\country in {0.5/4.1/Rumänien, %\x ist Anfang der Säulen
2/3.7/Griechenland, %\y ist Höhe der Säulen
3.5/3.5/Spanien,
5/3.5/Polen,
6.5/1.9/Großbritannien,
8/1.5/Niederlande,
9.5/1.2/Frankreich,
11/0.9/Deutschland,
12.5/0.5/Portugal,
14/0.1/Italien}
{
\draw[fill=myblue] (\x cm,0cm) rectangle (1cm+\x cm,\y cm) %die Säulen
node at (0.5cm + \x cm,\y cm + 0.3cm) {\y}; %die Prozente über den Säulen
\node[rotate=45, left] at (0.6 cm +\x cm,-0.1cm) {\country}; %Säulenbeschriftung
};
\end{tikzpicture}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Bar Plot with logarithmic Scale
My impression was that you did not. And a concrete answer to your question is: „Yes. It is possible“. And you got already suggestions for two packages that can help here.elect wrote:I know what you mean, and I did, but very quickly, because if you take care to my post, my goal is to know whether it is possible having bar plot and logarithmic axes […]
Unfortunately it's not because not working out of the box. Since you decided to use pgf/tikZ, I again strongly recommend to have a look at the pgfplots package. It will make life easier. At the moment I have not enough time to build an example from scratch.elect wrote:[…] Btw, I think this is what you meant: […]
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Bar Plot with logarithmic Scale
Perfect, thankslocalghost wrote: My impression was that you did not. And a concrete answer to your question is: „Yes. It is possible“. And you got already suggestions for two packages that can help here.

I didnt really decide it, that was what I found by googling..
I have read carefully the bar plot section in the pgfplots manual (here) but I did not find anything regarding logarithmic axes..
However also the examples in that section use pgf/tikZ or am I wrong? (from page 44)
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Bar Plot with logarithmic Scale
The link leads to an outdated version of the manual. A better reference is CTAN. You can also access a package manual instantly on the command line.elect wrote:[…] I have read carefully the bar plot section in the pgfplots manual (here) but I did not find anything regarding logarithmic axes.. […]
Code: Select all
texdoc pgfplots
The examples use of course pgfplots, which is based on pgf/tikZ (as already mentioned).elect wrote:[…] However also the examples in that section use pgf/tikZ or am I wrong? (from page 44)
In the meantime I have worked out a minimal example. You should be able to modify it till it fits your needs.
Code: Select all
\documentclass{minimal}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[%
width=14cm,height=7cm,
ybar,
xlabel={x axis},
ylabel={y axis},
xlabel near ticks,
ylabel near ticks,
ymin=0,ymax=1000,
x tick label style={rotate=45,anchor=east},
ytickten={1,2,3},
symbolic x coords={%
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine
}
]
\addplot coordinates {%
(One,17)
(Two,8)
(Three,23)
(Four,54)
(Five,234)
(Six,477)
(Seven,233)
(Eight,917)
(Nine,121)
};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}
[1] PGFPlots – A LaTeX package to create plots
[2] Logarithmisches Balkendiagramm mit pgfplots .:. goLateX – Mein LaTeX-Forum
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Bar Plot with logarithmic Scale
Thankslocalghost wrote: The link leads to an outdated version of the manual. A better reference is CTAN.
Perfect, thanks again..localghost wrote: In the meantime I have worked out a minimal example. You should be able to modify it till it fits your needs.If you decide to do some similar plots, you should know that there is one important hitch. Since there is a bug concerning bar plots and logarithmic axes in the current release version 1.5, you may need the development version of the package [1,2]. However, the above example looks OK with the current stable release version.Code: Select all
\documentclass{minimal} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{semilogyaxis}[% width=14cm,height=7cm, ybar, xlabel={x axis}, ylabel={y axis}, xlabel near ticks, ylabel near ticks, ymin=0,ymax=1000, x tick label style={rotate=45,anchor=east}, ytickten={1,2,3}, symbolic x coords={% One, Two, Three, Four, Five, Six, Seven, Eight, Nine } ] \addplot coordinates {% (One,17) (Two,8) (Three,23) (Four,54) (Five,234) (Six,477) (Seven,233) (Eight,917) (Nine,121) }; \end{semilogyaxis} \end{tikzpicture} \end{document}
I just don't know how to solve this:
Code: Select all
% Preamble:
\begin{tikzpicture}
\begin{semilogxaxis}[
xbar,
symbolic y coords={AMD Phenom II X4 955 3.2GHz,GeForce GTX 285 },
ytick=data,
]
\addplot coordinates {(7,AMD Phenom II X4 955 3.2GHz) (9,GeForce GTX 285) };
\addplot coordinates {(8,AMD Phenom II X4 955 3.2GHz) };
\end{semilogxaxis}
\end{tikzpicture}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Bar Plot with logarithmic Scale
At the moment I have no idea. I'm not sure if this is a bug.elect wrote:[…] I just don't know how to solve this: […] You can see that some space is reserved for the second "/addplot" also for the GeForce... how can I avoid that?
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10