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)

  1. groups, the np.array of group labels as output by create_data().
  2. data, the np.array of data as output by create_data().
  3. m_rows, the number of desired rows in your faceted histogram (explanation coming).
  4. m_cols, the number of desired columns in your faceted histogram (explanation coming).
  5. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!