Histogram and Box plots
1. test_hist_of_a_sample_normal_distribution
Create a figure of size 8 inches in width, and 6 inches in height. Name it as fig.
Create an axis, associated with figure fig, using add_subplot. Name it as ax.
Set random seed to 100 using the expression np.random.seed(100).
Create a normal distribution x1 of 1000 values, with mean 25 and standard deviation 3.0. Use
np.random.randn.
Draw a histogram of x1 with 30 bins. Use the hist function.
Label X-Axis as X1
Label Y-Axis as Bin Count
Set Title as Histogram of a Single Dataset.
In [9]:
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(111)
np.random.seed(100)
x1 = 25 + 3.0*np.random.randn(1000)
ax.set(title="Histogram of a Single Dataset", xlabel="X1", ylabel="Bin
Count")
plt.hist(x1,bins=30)