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

1. What is a histogram and how is it used in Python?

A histogram is a graphical representation of the distribution of numerical data. In Python, it is created using the matplotlib library and can be used to visualize the frequency or probability distribution of a dataset.

2. How do I create a histogram in Python?

To create a histogram in Python, you can use the matplotlib.pyplot.hist() function. This function takes in a dataset as input and automatically calculates the appropriate number of bins and plots the histogram. You can also adjust the number of bins and other parameters to customize the histogram.

3. What is a boxplot and how is it different from a histogram?

A boxplot is a graphical representation of the distribution of numerical data through quartiles and outliers. Unlike a histogram, which shows the frequency of data points, a boxplot shows the spread and skewness of the data. It is created using the matplotlib library in Python.

4. How do I create a boxplot in Python?

To create a boxplot in Python, you can use the matplotlib.pyplot.boxplot() function. This function takes in a dataset as input and automatically calculates the quartiles and outliers to create the boxplot. You can also customize the appearance of the boxplot by adjusting the parameters.

5. 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 subplots function from the matplotlib library. This function allows you to create multiple plots in a single figure, making it easy to compare the distributions of different datasets.

Similar threads

Replies
6
Views
2K
  • Programming and Computer Science
Replies
1
Views
5K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
1
Views
6K
  • Advanced Physics Homework Help
Replies
3
Views
2K
  • High Energy, Nuclear, Particle Physics
Replies
1
Views
3K
  • STEM Academic Advising
Replies
5
Views
949
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
30K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
994
Back
Top