Boxplot
import [Link] as plt
from [Link] import boxplot, show # Required libraries for boxplot
values = [2, 3, 4, 1, -3.04, 5, 4, 6, 7, 2, 4, 6, 8, 6 , 9, 12, 14, 11, 5, 16] # Data points (unordered)
[Link](values, vert=True, showfliers=True) # Create a simple boxplot
[Link]() # Display the boxplot
[Link](values, showfliers=False, vert=False) # Boxplot without outliers and in horizontal view
[Link]() # Display the boxplot
[Link](values, whis="range", vert=False) # Boxplot considering all data points within range
[Link]() # Display the boxplot
[Link](values, meanline=True, showmeans=True, vert=True) # Display mean line in the boxplot
[Link]() # Display the boxplot
# To plot multiple boxplots on one plane
import numpy as np
collectn_1 = [Link](100, 10, 200) # Generate random data
collectn_2 = [Link](80, 30, 200)
collectn_3 = [Link](90, 20, 200)
values = [collectn_1, collectn_2, collectn_3] # List of data sets
[Link](values, showmeans=True, meanline=True) # Display multiple boxplots
[Link]() # Display the boxplots
Histogram Notebook
import [Link] as plt
import numpy as np
x = [Link](170, 10, 250) # Generate random data with normal distribution
[Link](x) # Plot histogram
[Link]() # Display the histogram
# Detailed explanation of histogram syntax and parameters
[Link](x, bins=None, range=None, density=False, weights=None, cumulative=False,
histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None,
stacked=False, *, data=None, **kwargs)
import numpy as np
import [Link] as plt
x = [21,22,23,4,5,6,77,8,9,10,31,32,33,34,35,36,37,18,49,50,100]
n_bins = 10 # Number of bins for histogram
bin_heights, bins, patches = [Link](x, bins=10, facecolor='cyan') # Plot histogram with cyan color
[Link]() # Display the histogram
bin_heights # Check the bin heights
Histogram Notebook Commands
1. import [Link] as plt
o Syntax: import [Link] as plt
2. [Link]()
o Syntax: [Link](data, bins=10, range=None, density=False,
facecolor='cyan')
o Parameters:
data: Data for which the histogram is plotted.
bins: Number of bins (divisions of the x-axis).
range: Lower and upper range of the bins.
density: Whether to normalize the histogram (True/False).
facecolor: Color of the bars.
3. [Link]()
o Syntax: [Link](loc=170, scale=10, size=250)
o Explanation: Generates random numbers following a normal distribution with
specified mean and standard deviation.
4. [Link]()
o Syntax: p [Link]()
o Explanation: Displays the current plot on the screen.
5. Accessing Bin Heights
o Syntax: bin_heights, bins, patches = [Link](data, bins=10)
o Explanation: Captures information about the histogram, such as the heights of
the bins and their boundaries.