In [27]:
"""
simple demo of a horizontal bar chart
"""
import pandas
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline

In [28]:
plt.rcdefaults()

In [29]:
fig, ax = plt.subplots()
# Example data
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))

In [30]:
ax.barh(y_pos, performance, xerr=error, align='center',
       color='green', ecolor='black')


Out[30]:
<Container object of 5 artists>

In [31]:
ax.set_yticks(y_pos)


Out[31]:
[<matplotlib.axis.YTick at 0x10fa1f898>,
 <matplotlib.axis.YTick at 0x10fa0afd0>,
 <matplotlib.axis.YTick at 0x10fa1bf28>,
 <matplotlib.axis.YTick at 0x10fa7bf98>,
 <matplotlib.axis.YTick at 0x10fa819b0>]

In [32]:
ax.set_yticklabels(people)


Out[32]:
[<matplotlib.text.Text at 0x10fa23ac8>,
 <matplotlib.text.Text at 0x10fa11438>,
 <matplotlib.text.Text at 0x10fa7bdd8>,
 <matplotlib.text.Text at 0x10fa817f0>,
 <matplotlib.text.Text at 0x10fa85208>]

In [33]:
ax.invert_yaxis()

In [34]:
ax.set_xlabel('Performance')


Out[34]:
<matplotlib.text.Text at 0x10fa0aa20>

In [35]:
ax.set_title('How fast do you want to go today?')


Out[35]:
<matplotlib.text.Text at 0x10fa1f5f8>

In [36]:
plt.show()



In [37]:
x = np.linspace(0, 1, 500)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)
fig, ax = plt.subplots()
ax.fill(x, y, zorder=10)
ax.grid(True, zorder=5)
plt.show()



In [39]:
forest_fires = pandas.read_csv('../data/forestfire/forestfires.csv')

In [40]:
forest_fires.head(5)


Out[40]:
X Y month day FFMC DMC DC ISI temp RH wind rain area
0 7 5 mar fri 86.2 26.2 94.3 5.1 8.2 51 6.7 0.0 0.0
1 7 4 oct tue 90.6 35.4 669.1 6.7 18.0 33 0.9 0.0 0.0
2 7 4 oct sat 90.6 43.7 686.9 6.7 14.6 33 1.3 0.0 0.0
3 8 6 mar fri 91.7 33.3 77.5 9.0 8.3 97 4.0 0.2 0.0
4 8 6 mar sun 89.3 51.3 102.2 9.6 11.4 99 1.8 0.0 0.0

In [41]:
weight = [600, 150, 200, 300, 200, 100, 125, 180]

In [42]:
height = [60, 65, 73, 70, 65, 58, 66, 67]

In [43]:
len(weight), len(height)


Out[43]:
(8, 8)

In [44]:
plt.scatter(height, weight)
plt.show()



In [47]:
plt.scatter(forest_fires["wind"], forest_fires["area"])
plt.title('Wind speed vs fire area')
plt.xlabel('Wind speed when fire started')
plt.ylabel('Area consumed by fire')
plt.show()



In [48]:
age = [5, 10, 15, 20 ,25, 30]
height = [25, 45, 65, 75, 75, 75]
plt.plot(age, height)
plt.title('Age vs Height')
plt.xlabel('age')
plt.ylabel('Height')
plt.show()



In [49]:
area_by_month = forest_fires.pivot_table(index="month", values="area",aggfunc=np.sum)

In [50]:
type(area_by_month)


Out[50]:
pandas.core.series.Series

In [52]:
plt.bar(range(len(area_by_month)), area_by_month)
plt.title('Month vs Area')
plt.xlabel('month')
plt.ylabel('area')
plt.show()



In [53]:
plt.barh(range(len(area_by_month)), area_by_month)
plt.title('Month vs Area')
plt.xlabel('month')
plt.ylabel('area')
plt.show()



In [54]:
plt.style.use('fivethirtyeight')
plt.plot(forest_fires['rain'], forest_fires['area'])
plt.show()



In [57]:
plt.style.use('bmh')
plt.plot(forest_fires['rain'], forest_fires['area'])
plt.show()



In [ ]: