Matplotlib
keyboard_arrow_down 83 guides
chevron_leftGraphs Cookbook
Drawing a bar chartDrawing a box plotDrawing a functionDrawing a histogramDrawing a horizontal lineDrawing a line plotDrawing a normal curveDrawing a scatterplotDrawing a single pointDrawing a stacked bar chartDrawing a vertical lineDrawing arrowsDrawing circlesDrawing empty circlesDrawing error barsDrawing horizontal bar plotsDrawing multiple histograms in one plotNormalizing a histogramPlotting scatter plot with category
check_circle
Mark as learned thumb_up
0
thumb_down
0
chat_bubble_outline
0
Comment auto_stories Bi-column layout
settings
Drawing a box plot in Matplotlib
schedule Aug 12, 2023
Last updated local_offer
Tags Python●Matplotlib
tocTable of Contents
expand_more Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!
Start your free 7-days trial now!
To draw a box plot in Matplotlib use the boxplot(~)
method:
import matplotlib.pyplot as plt
x1 = [2,3,5,6]x2 = [2,6,10,15]
plt.boxplot([x1, x2])
# We place labels "x1" and "x2" in tick positions 1 and 2, respectivelyplt.xticks([1,2], ["x1","x2"])plt.xlabel("My x variables")plt.title("My box plot")plt.show()
This produces the following plot:
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
Official Matplotlib Documentation
https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.boxplot.html
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!