KnowledgeBoat Logo
|

Informatics Practices

Which of the following statements is used to create a histogram of 'step' type with 20 bins?

  1. plt.hist(x, bins = 20, histtype = "barstacked")
  2. plt.hist(x, bins=20)
  3. plt.hist(x, bins=20, histtype="step")
  4. plt.hist(x, bins=20, histtype=hist())

PyPlot

1 Like

Answer

plt.hist(x, bins=20, histtype="step")

Reason — The histtype parameter in the hist() function is used to specify the type of histogram to be created. In this case, histtype="step" is used to create a step histogram. The bins=20 parameter specifies that the histogram should be divided into 20 bins. Hence, the correct statement is plt.hist(x, bins=20, histtype="step").

Answered By

2 Likes


Related Questions