2

I created a computer model (just for fun) to predict soccer match result. I ran a computer simulation to predict how many points that a team will gain. I get a list of simulation result for each team.

I want to plot something like confidence interval, but using bar chart.

I considered the following option:

  • I considered using matplotlib's candlestick, but this is not Forex price.
  • I also considered using matplotlib's errorbar, especially since it turns out I can mashes graphbar + errorbar, but it's not really what I am aiming for. I am actually aiming for something like Nate Silver's 538 election prediction result.

enter image description here

Nate Silver's is too complex, he colored the distribution and vary the size of the percentage. I just want a simple bar chart that plots on a certain range.

I don't want to resort to plot bar stacking like shown here

Community
  • 1
  • 1
Realdeo
  • 449
  • 6
  • 19

1 Answers1

5

Matplotlib's barh (or bar) is probably suitable for this:

import numpy as np
import matplotlib.pylab as pl

x_mean = np.array([1,   3, 6  ])
x_std  = np.array([0.3, 1, 0.7])
y      = np.array([0,   1,  2 ])

pl.figure()
pl.barh(y, width=2*x_std, left=x_mean-x_std)

The bars have a horizontal width of 2*x_std and start at x_mean-x_std, so the center denotes the mean value.

It's not very pretty (yet), but highly customizable:

enter image description here

Bart
  • 9,825
  • 5
  • 47
  • 73