Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

For the MWE below:

\documentclass{report}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tikz,pgf}


\usepackage{pgfplots}
\usepackage{slashbox}
\usepackage{bchart}


\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols,automata}

\begin{document}

\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
ybar,
ylabel={Time Elapsed (in hours)},
xlabel={Methods},
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
width=0.8*\textwidth,
height=9cm,
bar width=7pt,
symbolic x coords={Category-1,Category-2,Category-3},
xtick=data,
%nodes near coords,
%nodes near coords align={vertical},
]
        \addplot
        coordinates {(Category-1,0.14) (Category-2,2) (Category-3,13.25)};
        \addplot
        coordinates {(Category-1,2.76) (Category-2,2) (Category-3,29.55)};
        \addplot
        coordinates {(Category-1,2.81) (Category-2,2) (Category-3,16.04)};
        \legend{byHalf, Random, Hybrid}
    \end{axis}
\end{tikzpicture}
\end{figure}

\end{document}

How can I make my x-label move up so that it touches the bars ?

enter image description here

share|improve this question
    
Adding ymin=0 to the axis options seems to do the job. –  Peter Grill Aug 29 '12 at 1:56
    
@PeterGrill yes this is actually what I needed to achieve thanks! –  Cemre Aug 29 '12 at 2:13

1 Answer 1

up vote 2 down vote accepted

There seems to be a discrepancy between the title and the question in the body. I am answering the question posed in the title.

If you add ymin=0 to the axis you get:

enter image description here

Code:

\documentclass{report}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tikz,pgf}


\usepackage{pgfplots}
\usepackage{slashbox}
\usepackage{bchart}


\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols,automata}

\begin{document}

\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
ybar,
ylabel={Time Elapsed (in hours)},
xlabel={Methods},
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
width=0.8*\textwidth,
height=9cm,
bar width=7pt,
symbolic x coords={Category-1,Category-2,Category-3},
xtick=data,
%nodes near coords,
%nodes near coords align={vertical},
]
        \addplot
        coordinates {(Category-1,0.14) (Category-2,2) (Category-3,13.25)};
        \addplot
        coordinates {(Category-1,2.76) (Category-2,2) (Category-3,29.55)};
        \addplot
        coordinates {(Category-1,2.81) (Category-2,2) (Category-3,16.04)};
        \legend{byHalf, Random, Hybrid}
    \end{axis}
\end{tikzpicture}
\end{figure}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.