Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python boxplot legend

import matplotlib.pyplot as plt
import numpy as np; np.random.seed(1)

data1=np.random.randn(40,2)
data2=np.random.randn(30,2)

fig, ax = plt.subplots()
bp1 = ax.boxplot(data1, positions=[1,4], notch=True, widths=0.35, 
                 patch_artist=True, boxprops=dict(facecolor="C0"))
bp2 = ax.boxplot(data2, positions=[2,5], notch=True, widths=0.35, 
                 patch_artist=True, boxprops=dict(facecolor="C2"))

ax.legend([bp1["boxes"][0], bp2["boxes"][0]], ['A', 'B'], loc='upper right')

ax.set_xlim(0,6)
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: how to get the current url path in django template 
Python :: django gunicorn static file not found 
Python :: django form datepicker 
Python :: python find which os 
Python :: python histogram as a dictionary 
Python :: Addition/subtraction of integers and integer-arrays with DatetimeArray is no longer supported 
Python :: how to create list from a to z in python 
Python :: `distplot` is a deprecated function and will be removed in a future version 
Python :: python replace multiple spacis with spaces 
Python :: pandas drop columns by index 
Python :: get variance of list python 
Python :: gpu training tensorflow 
Python :: transparancy argument pyplot 
Python :: new event loop asyncio 
Python :: numpy ones 
Python :: python print without space 
Python :: boston dataset sklearn 
Python :: python every other goes to a list 
Python :: binary number in python 32 bit 
Python :: python get square root 
Python :: string pattern matching pandas 
Python :: change text color docx-python 
Python :: python system of equations 
Python :: convert array to dataframe python 
Python :: pyhton turtle delete 
Python :: python selenium assert presence of an element 
Python :: get the last element of a list python 
Python :: pycharm remove not in use imports 
Python :: how to get iheight in pyqt5 
Python :: split list in 3 part 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =