Drawing bar chart with x axis label only visible in legend?

I want to draw a bar chart with x axis label empty and the color of the filling reflecting the axis label from legend. Similar to this one here.

My code is as follows:

\documentclass[12pt, a4paper, titlepage]{scrartcl}

\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\graphicspath{{./Figures/}}

\usepackage{url}
%\usepackage{titlesec}
%\newcommand{\sectionbreak}{\clearpage}
\usepackage{dirtree}
\usepackage{color}
\usepackage{listings}
\usepackage{caption}
\usepackage{pdfpages}
\usepackage{pgfplots}
\newcommand{\courierword}[1]{\textsf{\itshape #1}}{\fontfamily{pcr}\selectfont}%
\setlength{\parindent}{0.0cm}
\setlength{\parskip}{1ex}

\setkomafont{sectioning}{\normalcolor\bfseries}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
ylabel=Time(s),
]
coordinates{(Make Clean,14)};
\legend{Make Clean, Gradle Clean}
\end{axis}
\end{tikzpicture}

\end{document}

• It would be nice if you could complete your code and make it compilable by including the 'documentclass' that you are using, as well as relevant packages.
– Troy
Mar 14 '17 at 15:13
• It doesn't compile as of now. There are errors. Mar 14 '17 at 15:22

I am not sure if I understand what you want to do: \documentclass[margin=5pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.14}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
ylabel=Time(s),
ymin=0,
xtick=\empty,
enlarge x limits={abs=\pgfplotbarwidth/2},
ybar=-\pgfplotbarwidth,% ybar must be -bar width
x=\pgfplotbarwidth,
bar width=30pt,
legend style={
cells={anchor=west},
legend pos=outer north east,
}
]
%
%
%
\legend{Make Clean,Gradle Clean,Test 1,Test 2}
\end{axis}
\end{tikzpicture}

\end{document}


results in

• This is exactly how I wanted to do it. However, I want the bars to be grouped. Like, bars for Make Clean & Gradle Clean next to each other, then Test 1 and Test 2 next to each other. Mar 15 '17 at 8:21
• I have added option x=\pgfplotbarwidth to get the bars next to each other.
– esdd
Mar 15 '17 at 18:50