Histograms categories data by breaking it into bins, where each bin contains a subset of the data range. A histogram then displays the number of items in each bin so that you can see the distribution of data from bin to bin. In most cases, you see a curve of some type, such as a bell curve.
We will try to make a histogram for the height of Major League Baseball player from the provided csv. Height and weight of people usually gives a type of bell curve.
As a minimum, you must provide values to plot. The second argument contains the number of bins to use when creating the data intervals.
As with other charts, you can add special features. Here we add align and color.
Boxplots provide a means of depicting groups of numbers through their quartiles. A boxplot may also have lines, indicating data outside the upper and lower quartiles.
We will use the same data as the previous example. The call to boxplot() requires only data as input. All other parameters have default settings.
In the example, we make the code sets the presentation of outliers to red 'r' and X-shape 'x' (hence, sym='rx'). We can also adjust the widths (here we make it .75 wider)1. MLB Players Age
A. In this example, we are still using the mlb_players.csv. Make a histogram for the age of MLB players.
Try out different number of bins and find one that looks the best to you.
Set the histogram type to be 'step'.
Add a proper title.
B. Sometimes we want to add the density plot of our histogram. The library seaborn can help with this. Try to draw a histogram similar to part A with density plot using this library. This link and this link might help with the general idea. The style is up to you.
2. Age Boxplot
A. Make a boxplot representing MLB players age.
Make the outlier to be + shape with color blue, if there's any.
Adjust the width to be 50% larger (set it to .5).
Add a proper title.
B. In addition to boxplot, adding datapoints on top of the boxplot makes visualizing the data easier. This is usually called a swarmplot. Try to add the swarmplot on top of the boxplot using seaborn library. The style is up to you.