# Create a histogram of any one of the four features
import matplotlib.pyplot as plt
ax = plt.axes()
ax.hist(data.petal_length, bins=25);
ax.set(xlabel='Petal Length (cm)',
ylabel='Frequency',
title='Distribution of Petal Lengths');
plt.show()
import matplotlib.pyplot as plt
ax = data.petal_length.plot.hist(bins=20)
ax.set(xlabel='Petal Length (cm)',
ylabel='Frequency',
title='Distribution of Petal Lengths');
plt.show()
import matplotlib.pyplot as plt
data["petal_length"].hist(bins=25)
plt.title("Distribution of Petal Lengths")
plt.xlabel("Petal Length (cm)")
plt.ylabel("Frequency")
plt.show()
# Create a single plot with histograms for each feature overlayed
# If Seaborn is not imported
try:
import seaborn as sns
except:
print('Seaborn must be installed for this course. Execute the following:')
print('`conda install seaborn`')
print('from a terminal and restart the kernel.')
sns.set_context('notebook')
import matplotlib.pyplot as plt
ax = data.plot.hist(bins=25, alpha=0.5)
ax.set_xlabel('Size (cm)');
plt.show()
import matplotlib.pyplot as plt
data.plot(kind="hist", rot=50, bins=25, alpha=0.5)
plt.show()
# To create four separate plots
import matplotlib.pyplot as plt
axList = data.hist(bins=25)
for ax in axList.flatten():
if ax.is_last_row():
ax.set_xlabel('Size (cm)')
if ax.is_first_col():
ax.set_ylabel('Frequency')
#plt.show()