Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot matplotlib errorbars

I tried to plot error bar with Matplotlib like graphic attached, I can't made it, any suggestion?

import numpy as np
import matplotlib.pyplot as plt

Media   = data["Media"]
Periodo = data["Periodo"]
P10th     = data["P10th"]
P90th     = data["P90th"]
ind = np.arange(N)    # the x locations for the groups

width = 0.35       # the width of the bars: can also be len(x) sequence

fig, ax = plt.subplots()

ax.errorbar(Media, P90th, P10th, color='red', ls='--', marker='o', capsize=5, capthick=1, ecolor='black')
plt.xticks(ind, ('1910-1940', '1950-1990', '1990-2000', '2001-2010') )
ax.set_ylim(ylims)

I tried to plot with marplotlib this kind of graphic

here my data, please can you help me.

This is my output

enter image description here

like image 634
Juan Carlos Avatar asked Sep 05 '25 02:09

Juan Carlos


1 Answers

Here's the plot for your data:

p_10 = [.19,.62, .77, 1]
p_90 = [7.19, 6.67, 7.36, 8.25]
M = [1.16, 2.06, 2.17, 2.52]

fig = plt.figure()
x = [1, 2, 3, 4]
y = M
yerr = [p_10, # 'down' error
        p_90]  # 'up' error

plt.errorbar(x, y, yerr=yerr, capsize=3, fmt="r--o", ecolor = "black")

enter image description here

like image 72
Roy2012 Avatar answered Sep 07 '25 07:09

Roy2012