目录
02 Deviation
2.0 Prerequisite
-
Setup.py
# !pip install brewer2mpl
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import warnings; warnings.filterwarnings(action='once')
large = 22; med = 16; small = 12
params = {
'axes.titlesize': large,
'legend.fontsize': med,
'figure.figsize': (16, 10),
'axes.labelsize': med,
'axes.titlesize': med,
'xtick.labelsize': med,
'ytick.labelsize': med,
'figure.titlesize': large}
plt.rcParams.update(params)
# plt.style.use('seaborn-whitegrid')
plt.style.use("seaborn-v0_8")
sns.set_style("white")
# %matplotlib inline
# Version
print(mpl.__version__) #> 3.7.1
print(sns.__version__) #> 0.12.2
2.1 发散型条形图(Diverging Bars)
-
If you want to see how the items are varying based on a single metric and visualize the order and amount of this variance, the diverging bars is a great tool. It helps to quickly differentiate the performance of groups in your data and is quite intuitive and instantly conveys the point.
-
mtcars.csv描述了汽车燃油效率的发散型点图,其数据如下所示:
"mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb","fast","cars","carname"
4.58257569495584,6,160,110,3.9,2.62,16.46,0,1,4,4,1,"Mazda RX4","Mazda RX4"
4.58257569495584,6,160,110,3.9,2.875,17.02,0,1,4,4,1,"Mazda RX4 Wag","Mazda RX4 Wag"
4.77493455452533,4,108,93,3.85,2.32,18.61,1,1,4,1,1,"Datsun 710","Datsun 710"
4.62601340248815,6,258,110,3.08,3.215,19.44,1,0,3,1,1,"Hornet 4 Drive","Hornet 4 Drive"
4.32434966208793,8,360,175,3.15,3.44,17.02,0,0,3,2,1,"Hornet Sportabout","Hornet Sportabout"
4.25440947723653,6,225,105,2.76,3.46,20.22,1,0,3,1,1,"Valiant","Valiant"
3.78153408023781,8,360,245,3.21,3.57,15.84,0,0,3,4,0,"Duster 360","Duster 360"
4.93963561409139,4,146.7,62,3.69,3.19,20,1,0,4,2,1,"Merc 240D","Merc 240D"
4.77493455452533,4,140.8,95,3.92,3.15,22.9,1,0,4,2,1,"Merc 230","Merc 230"
4.38178046004133,6,167.6,123,3.92,3.44,18.3,1,0,4,4,1,"Merc 280","Merc 280"
4.2190046219458,6,167.6,123,3.92,3.44,18.9,1,0,4,4,1,"Merc 280C","Merc 280C"
4.04969134626332,8,275.8,180,3.07,4.07,17.4,0,0,3,3,1,"Merc 450SE","Merc 450SE"
4.15932686861708,8,275.8,180,3.07,3.73,17.6,0,0,3,3,1,"Merc 450SL","Merc 450SL"
3.89871773792359,8,275.8,180,3.07,3.78,18,0,0,3,3

最低0.47元/天 解锁文章
845

被折叠的 条评论
为什么被折叠?



