Question: Write a function called facet_hist(). This function should accept five arguments: def create_data(n, n_groups): groups = np.random.randint(0, n_groups, n) data = np.sin(groups) + np.random.randn(n) return(groups,
Write a function called facet_hist(). This function should accept five arguments:
def create_data(n, n_groups): groups = np.random.randint(0, n_groups, n) data = np.sin(groups) + np.random.randn(n) return(groups, data)
- groups, the np.array of group labels as output by create_data().
- data, the np.array of data as output by create_data().
- m_rows, the number of desired rows in your faceted histogram (explanation coming).
- m_cols, the number of desired columns in your faceted histogram (explanation coming).
- figsize, the size of the figure.
Your function will create faceted histograms -- that is, a separate axis and histogram for each group. For example, if there are six groups in the data, then you should be able to use the code
groups, data = create_data(1000, 6) facet_hist(groups, data, m_rows = 2, m_cols = 3, figsize = (6,4))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
