Help with Histogram and Boxplot in Python

In summary, a transfer student with a disorganized course load is seeking help with a statistics assignment that requires the use of Python to create a boxplot and histogram. They have no prior coding experience and are unsure of where to begin. The data provided is annual rainfall in Los Angeles for the month of February from 1965 to 2006. The student is expected to use pyplot for their plots but is unfamiliar with ASCII or graphics toolkits. More effort is needed to receive assistance and examples of pyplot can be found through a search engine.
  • #1
SShep71
5
0
I could really use some help here, I am a transfer student so my course load is all out of order. I have a statistics course that requires me to use Python to solve this one question (the 2 parts shown below). I never took any sort of coding before, I don't know where to even start. Can anyone help with this boxplot and histogram? So I can input it into my Lab report.
The weather in Los Angeles is dry most of the time, but it can be quite rainy in the winter. The rainiest month of the year is February. The following table presents the annual rainfall in Los Angeles, in inches, for each February from 1965 to 2006.

Using Python:

2) Construct a histogram for these data.

4) Construct a boxplot for these data. Does the box-plot show any outliers?
php7Y0XKA.png
 
Technology news on Phys.org
  • #2
You will need to show a lot more effort than that to get much help from us. What graphics toolkit (Tk) do you have that you want to use to plot these histograms? Or are you expected to plot them using ASCII output...?
 
  • #3
I really want to provide more, but I honestly don't know what ASCII or a toolkit is at this point. The only programming I have ever done is G-code for CNC machine. All my instructions say is" Provide Python code and two plots" for the question and two plots.
 
  • #4
berkeman said:
You will need to show a lot more effort than that to get much help from us. What graphics toolkit (Tk) do you have that you want to use to plot these histograms? Or are you expected to plot them using ASCII output...?
I would guess that the OP is expected to use pyplot. Examples of histograms and box plots using pyplot can be located with a search engine.
 
Last edited:
  • Informative
Likes berkeman

FAQ: Help with Histogram and Boxplot in Python

How do I create a histogram in Python?

To create a histogram in Python, you can use the matplotlib library. First, import matplotlib.pyplot as plt. Then, use the plt.hist() function passing in the data you want to plot and specify the number of bins.

How can I customize the appearance of a histogram in Python?

You can customize the appearance of a histogram in Python by using various parameters in the plt.hist() function. For example, you can change the color of the bars, add labels to the x and y axes, and adjust the range of the x-axis using the range parameter.

How do I create a boxplot in Python?

To create a boxplot in Python, you can use the seaborn library. First, import seaborn as sns. Then, use the sns.boxplot() function passing in the data you want to plot and specify the x-axis and y-axis variables.

Can I create a histogram and boxplot side by side in Python?

Yes, you can create a histogram and boxplot side by side in Python using the matplotlib library. You can use the plt.subplot() function to create multiple plots in the same figure and then plot the histogram and boxplot in separate subplots.

How can I save a histogram or boxplot as an image in Python?

You can save a histogram or boxplot as an image in Python using the plt.savefig() function from the matplotlib library. Simply call plt.savefig() passing in the file path and format (e.g., 'png', 'jpg') to save the plot as an image.

Back
Top