import
matplotlib.pyplot as plt
import
numpy as np
names
=
[
'USA'
,
'India'
,
'England'
,
'China'
]
x
=
np.arange(
4
)
economy
=
[
21.43
,
2.87
,
2.83
,
14.34
]
error
=
[
1.4
,
1.5
,
0.5
,
1.9
]
error1
=
[
0.5
,
0.2
,
0.6
,
1
]
colors
=
[
'red'
,
'grey'
,
'blue'
,
'magenta'
]
fig, ax
=
plt.subplots()
ax.bar(x, economy, alpha
=
0.5
,
color
=
colors)
for
pos, y, err,err1, colors
in
zip
(x, economy,
error, error1,
colors):
ax.errorbar(pos, y, err, err1, fmt
=
'o'
,
lw
=
2
, capsize
=
4
, capthick
=
4
,
color
=
colors)
ax.set_ylabel(
'Economy(in trillions)'
)
ax.set_xticks(x)
ax.set_xticklabels(names)
ax.set_xlabel(
'Name of the countries'
)
plt.show()