# drawing horizontal line on bar chart

Hi,

I am plotting overlapping bars in a bar chart. In some places one bar
overlaps the other so I would like to draw a horizontal line to show where
the underlying bar extends to. My plots are postscripts so I can't use
alpha. The only way I could come up with involves me figuring out by trial
and error where each bar starts, for example:

bar_width = 0.068
xmin_line = 0.198
xmax_line = xmin_line+bar_width
plt.axhline(y=data_biomass[2], xmin=xmin_line, xmax=xmax_line, linewidth=2,
color="b")

Is there a way I can work out where each bar starts and how wide it is? I
tried ax.get_xticks, but these don't match with the above function which
only seems to be a fraction of 0 - 1.

thanks,

Martin

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/drawing-horizontal-line-on-bar-chart-tp41333.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

This kind of sounds like stack plots, but I am not quite sure.

Cheers!
Ben Root

···

On Jun 29, 2013 1:45 AM, “mdekauwe” <mdekauwe@…287…> wrote:

Hi,

I am plotting overlapping bars in a bar chart. In some places one bar

overlaps the other so I would like to draw a horizontal line to show where

the underlying bar extends to. My plots are postscripts so I can’t use

alpha. The only way I could come up with involves me figuring out by trial

and error where each bar starts, for example:

bar_width = 0.068

xmin_line = 0.198

xmax_line = xmin_line+bar_width

plt.axhline(y=data_biomass[2], xmin=xmin_line, xmax=xmax_line, linewidth=2,

color=“b”)

Is there a way I can work out where each bar starts and how wide it is? I

tried ax.get_xticks, but these don’t match with the above function which

only seems to be a fraction of 0 - 1.

thanks,

Martin

View this message in context: http://matplotlib.1069221.n5.nabble.com/drawing-horizontal-line-on-bar-chart-tp41333.html

Sent from the matplotlib - users mailing list archive at Nabble.com.

This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Yes and no. My understanding of stacked bars is the bar stacked on top is
always larger than the one below. I am trying to show how much the second
bar explains of the first bar. In my case though it is possible the second
bar is larger than the first. As a consequence you wouldn't see both bars
and this is why I want to draw a line to show where the other bar extends
to.the

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/drawing-horizontal-line-on-bar-chart-tp41333p41341.html
Sent from the matplotlib - users mailing list archive at Nabble.com.