<jupyter_start><jupyter_text>Summary of the history of the box plot.  A box plot is a visual represenation of the statistical five number summary a the data set that is given. This includes                       1.Minimum                      2.First Quartile                      3.Median (second quartile)                     4. Third quartile                     5. Maximum ![<NAME>](per5.png)  Mathematican <NAME> was the first to introduce the Box and WHisker plot in 1969 to show a visual summery of the five number summary of any given data set. A man called <NAME> describes them, he says boxplots use robust summary statistics that are always located at  actual data points, are quickly computable and have no tuning parameters, and are usefull to compare distributions across groups. The chartio version is the closest to the original and is used to take a subset of data and quickly and visually show the  five number summary data set. But in the chartio version it has a tool tip is provided that shows all of the data points summarised in the visualisation.  Example of a boxplot<jupyter_code>import numpy as np
import matplotlib.pyplot as plt

# Fixing random state for reproducibility
np.random.seed(19680801)

# generate random nos in 50s
spread = np.random.rand(50) * 120
# center boxplot 25 x 50
center = np.ones(25) * 50
flier_high = np.random.rand(10) * 120 + 120
flier_low = np.random.rand(10) * -120
data = np.concatenate((spread, center, flier_high, flier_low))
# using basic plot
fig1, ax1 = plt.subplots()
ax1.set_title('Basic Plot')
ax1.boxplot(data)
plt.show()
# population = follwoing numbers of people
populationData = [8000000000, 12000000000, 6000000000, 75000000000, 1000000000, 120000000000, 150000000000]
#plot boxplot showing population data
plt.boxplot(populationData)
#show boxplot
plt.show()
populationData = [8000000000, 12000000000, 6000000000, 75000000000, 1000000000, 120000000000, 150000000000]
plt.boxplot(populationData)
# i now want to add title to top named population data
plt.title("population data")
# i now add a label to the y axes naming it ammount of people
plt.ylabel("Ammount of people")
plt.show()
# showing results in the lower quartile = less than 25%
# shows what directory i am in
pwd
# change directory
cd Boxplot
# import pandas package as pd
import pandas as pd
# read in the csv file by calling it population
population = pd.read_csv('population data.csv')
#print population
population
#top five rows of data
population.head()
# column names in the population data set
population.columns
# plot a boxplot for the vacant houses column
plt.boxplot(population['P_VACANT_HOUSES_LESS_HH11'])
# title to be vacant houses less hh11
plt.title("P_VACANT_HOUSES_LESS_HH11")
# plot label on y axis is to be ammount of people
plt.ylabel("Ammount of people")
# show plot
plt.show()
#plot a boxplot for population column
plt.boxplot(population['POPULATION_02'])
# title to be population data
plt.title("population data")
# on y axis ammount of people
plt.ylabel("Ammount of people")
# show plot
plt.show()
# plot a boxplot for population 06 column
plt.boxplot(population['POPULATION_06'])
# title to be population 06
plt.title("P_VACANT_HOUSES_LESS_HH11")
# on y axis ammount of people
plt.ylabel("Ammount of people")  
# show plot
plt.show()
# in this one we are using nothced boxes 
fig2, ax2 = plt.subplots()
ax2.set_title('Notched boxes')
ax2.boxplot(data, notch=True)
fig4, ax4 = plt.subplots()
#hiding outlier points
ax4.set_title('POPULATION')
ax4.boxplot(data, showfliers=False)
plt.show()
u = u"""index,location,population
    Dec 14,Darogue,15.0
    Dec 14,Darogue,45.0
    Dec 14,Darogue,50.0
    Dec 14,Darogue,120.0
    Dec 14,Darogue,300.0"""
# using my address darogue in fake data
# importing io which is a web based platform that helps extract data from websites without having to write out any code
import io
# import pandas package as pd
import pandas as pd
# import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
#data = string
data = io.StringIO(u)
# dataframe = read from csv file data sep and index is column 0
df = pd.read_csv(data, sep=",", index_col=0)
# boxplot of dataframe with population
plt.boxplot(df["population"])
## title is p vacant houses less h11
plt.title("P_VACANT_HOUSES_LESS_HH11")
#y label is ammount of people
plt.ylabel("Ammount of people")     
# show plot
plt.show()<jupyter_output><empty_output><jupyter_text>The five number summary the sample minimum, the lower quartile or the first quartile, the median, the upper quartile or the third quartile and the sample maximum.  In the boxplot we draw a box from the first quartile and the third quartile, a vertical line goes throught the box at the median, then the whiskers go from each quartile to the minimum or maximum.  Here we have a boxplot of a very well know data set known as the Iris data set. ![iris data set](per2.png)  Example & Explanation of  Finding the five-number summary and of the term QuartileA sample of 101010 boxes of raisins has these weights (in grams):252525, 282828, 292929, 292929, 303030, 343434, 353535, 353535, 373737, 383838Make a box plot of the data.Step 1: Order the data from smallest to largest.Our data is already in order.252525, 282828, 292929, 292929, 303030, 343434, 353535, 353535, 373737, 383838Step 2: Find the median.The median is the mean of the middle two numbers:252525, 282828, 292929, 292929, 30\large{30}30, 34\large{34}34, 353535, 353535, 373737, 38383830+34/2​=32The median is 323232.Step 3: Find the quartiles.The first quartile is the median of the data points to the left of the median.252525, 282828, 29\large{29}29, 292929, 303030Q1​=29The third quartile is the median of the data points to the right of the median.343434, 353535, 35\large{35}35, 373737, 383838Q3=35Q_3=35Q3​=35Step 4: Complete the five-number summary by finding the min and the max.The min is the smallest data point, which is 252525.The max is the largest data point, which is 383838.The five-number summary is 252525, 292929, 323232, 353535, 383838.  The boxplot is used when we have large amounts of data that need organising and it visualises the outlier values. An example of situations it could be used in is in measuring weather and temperatures where the dataset would contain all the weather data inclduing the temperature from all the weather stations in a partcular country during a specific time period. They would use teh average daily temperature caculated over a 24 hour period in celsius. The boxplot would containg the the following data properties, Dimension which would measure both date and year ensuring date comes first is very important. The second data property is Measure to measure the temperature degrees in celsius. The boxplot will show a visualisation of the daily temperture measurements, in the mean temperature order, which is illustrated by the middle line in each box. The box then stretches form the first quartile to the third quartile adn the whiskers stretch 1.5 inter quartile ranges. There are also other values that lie outside the whiskers which are call outlier values.   Below we can see a clear diagram of how to read a boxplot from the percentile aspect, showing for example the lower whisker and just above it is group 1 which is in the lower percentile group this may be good in some scenarios but bad in areas of health regarding height and weight abong the general population. ![quartile](per 3.png)  Demonstration of a boxplot with simple data.<jupyter_code>import pandas as pd
import numpy as np
# using numpy.random to generate nos form 10-5 using colsumns a,b,c,d,e. using 5 trials with 10 observations of a
# random variable
df = pd.DataFrame(np.random.rand(100, 5), columns=['A', 'B', 'C', 'D', 'E'])
df.plot.box(grid='True')
plt.show()
# show plot with heading p vacant houses less hh11
plt.title("P_VACANT_HOUSES_LESS_HH11")
# y label has ammount of poeple as heading
plt.ylabel("Ammount of people")     
# show plot
plt.show()
# import plotly package by running pup install and uograde from 3.11 to 3.4.2
import plotly
plotly.__version__
# import plotly.plotly as py
import plotly.plotly as py
# import plotly.tools as tls
import plotly.tools as tls

# import matplotlib.pyplot package as plt
import matplotlib.pyplot as plt
# import numpy package as np
import numpy as np
import plotly.plotly as py
import plotly.tools as tls

import matplotlib.pyplot as plt
import numpy as np

spread = np.random.rand(50) * 100
center = np.ones(25) * 50
flier_high = np.random.rand(10) * 100 + 100
flier_low = np.random.rand(10) * -100
data = np.concatenate((spread, center, flier_high, flier_low), 0)

mpl_fig = plt.figure()
ax = mpl_fig.add_subplot(111)

ax.boxplot(data)

ax.set_xlabel('Ammount of people')
ax.set_ylabel('population')
plt.show()
# boxplot with outliers we can se the data is centred here at the middle 50% percentile,<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06934921883781049, 'fraction_numerical': 0.07114757783522535, 'mean_word_length': 4.5682102628285355, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '545071', 'license': 'MIT', 'n_tokens_mistral': 3190, 'n_tokens_neox': 2661, 'n_words': 1213, 'path': '1boxplot.ipynb', 'repo_name': 'Maria1709/Boxplot', 'size': '8914'}