8

I am trying to create some nice looking bar plots, but this does not seem to be an easy task for me :) I have started out with the following:

\begin{tikzpicture}
  \begin{axis}[
      xbar, xmin=0,
      width=12cm, height=3.5cm, enlarge y limits=0.5,
      xlabel={Value},
      symbolic y coords={Instance1,Instance2},
      ytick=data,
      nodes near coords, nodes near coords align={horizontal},
      cycle list name=exotic
    ]
    \addplot coordinates {(3,Instance1) (7,Instance2)};
    \addplot coordinates {(2,Instance1) (3,Instance2)};
  \end{axis}
\end{tikzpicture}

This looks the following:

Bar plot

Instead I would prefer to only fill the bars without drawing and without the markers. I would still like to use the cycle list though. Any ideas on how to achieve this?

2 Answers 2

7

You can use

every axis plot/.append style={fill,draw=none,no markers}

as an option of the axis environment.

enter image description here

Code:

\documentclass[margin=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
      xbar, xmin=0,
      width=12cm, height=3.5cm, enlarge y limits=0.5,
      xlabel={Value},
      symbolic y coords={Instance1,Instance2},
      ytick=data,
      nodes near coords, nodes near coords align={horizontal},
      cycle list name=exotic,
      every axis plot/.append style={fill,draw=none,no markers}% <- added
    ]
    \addplot coordinates {(3,Instance1) (7,Instance2)};
    \addplot coordinates {(2,Instance1) (3,Instance2)};
  \end{axis}
\end{tikzpicture}
\end{document}
2
  • But then you would need \addplot+, right?
    – hfhc2
    Jun 25, 2015 at 13:31
  • No. There are no [ ...] behind the \addplot so the cycle list is still active. Only the options mentioned in every axis plot/.append style={fill,draw=none,no markers} are changed. And as you can see the colors of the cycle list are still used.
    – esdd
    Jun 25, 2015 at 13:37
1

Something like this: enter image description here

It is obtained by:

\documentclass[border=3mm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[
      xbar, xmin=0,
      width=12cm, height=3.5cm, enlarge y limits=0.5,
      xlabel={Value},
      symbolic y coords={Instance1,Instance2},
      ytick=data,
      nodes near coords, nodes near coords align={horizontal},
      cycle list name=exotic
    ]
\addplot[draw=none,mark=none,fill=blue] 
    coordinates {(3,Instance1) (7,Instance2)};
\addplot[draw=none,mark=none,mark=none,fill=red] 
    coordinates {(2,Instance1) (3,Instance2)};
  \end{axis}
\end{tikzpicture}\end{document}

The bar colors set to your taste.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .