matplotlib - How do I create a bar chart that starts and ends in a certain range -


i created computer model (just fun) predict soccer match result. ran computer simulation predict how many points team gain. list of simulation result each team.

i want plot confidence interval, using bar chart.

i considered following option:

  • i considered using matplotlib's candlestick, not forex price.
  • i considered using matplotlib's errorbar, since turns out can mashes graphbar + errorbar, it's not aiming for. aiming nate silver's 538 election prediction result.

enter image description here

nate silver's complex, colored distribution , vary size of percentage. want simple bar chart plots on range.

i don't want resort plot bar stacking shown here

matplotlib's barh (or bar) suitable this:

import numpy np import matplotlib.pylab 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 horizontal width of 2*x_std , start @ x_mean-x_std, center denotes mean value.

it's not pretty (yet), highly customizable:

enter image description here


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -