Is it possible to easily make a bar graph using pgfplots with text as
x-axis labels?
Content wise, I want something like this:
I would like to be able to have text (to be specific, % Copper) as the
x-axis labels. I also want the y-axis to have a scale of 0%-6% with each
1% intervals marked off with horizontal lines as shown.
Graphically, I want something like this:
Which is to say: have the legend on the bottom like so, but only have one
group of bars with one x-axis label. And without any tick marks like shown
in this example nor the red, horizontal line.
I got the pgfplots example from their sourceforge examples page. The
unmodified code to produce that is:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x tick label style={
/pgf/number format/1000 sep=},
ylabel=Population,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ybar,
bar width=7pt,
]
\addplot
coordinates {(1930,50e6) (1940,33e6)
(1950,40e6) (1960,50e6) (1970,70e6)};
\addplot
coordinates {(1930,38e6) (1940,42e6)
(1950,43e6) (1960,45e6) (1970,65e6)};
\addplot
coordinates {(1930,15e6) (1940,12e6)
(1950,13e6) (1960,25e6) (1970,35e6)};
\addplot[red,sharp plot,update limits=false]
coordinates {(1910,4.3e7) (1990,4.3e7)}
node[above] at (axis cs:1950,4.3e7) {Houses};
\legend{Far,Near,Here,Annot}
\end{axis}
\end{tikzpicture}
\end{document}
So far, all I've managed to produce from modifying that example is this:
Using this code:
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={Copper},
ylabel=Mass,
% enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ybar,
bar width=7pt,
width = \textwidth,
height = 0.5\textheight,
grid = major
]
\addplot
coordinates {(Copper,0.02)};
\addplot
coordinates {(Copper,0.05)};
\addplot
coordinates {(Copper,0.04)};
\addplot
coordinates {(Copper,0.03)};
\addplot
coordinates {(Copper,0.05)};
\addplot
coordinates {(Copper,0.038)};
\legend{First1 Last1, First2 Last2, First3 Last3, First4 Last4, First5
Last5, Average}
\end{axis}
\end{tikzpicture}
I have absolutely no idea what to do from here and I would rather not
include a picture in my otherwise completely vector-based PDF file. So,
any ideas?
No comments:
Post a Comment