Boxplot

In [123]: import numpy as np

               import matplotlib.pyplot as plt

In [124]: data = np.random.randn(100)

In [125]: plt.boxplot(data) #The red bar is the median of the distribution.

               plt.show()

https://i-blog.csdnimg.cn/blog_migrate/1014b0fd34b81f9923a4dd6a8a350a85.png

In [126]: import numpy as np

               import matplotlib.pyplot as plt

In [127]: data = np.random.randn(100,5)

In [128]: plt.boxplot(data)

               plt.show()

https://i-blog.csdnimg.cn/blog_migrate/72d160e7024716214b260d871ec3bd76.png

5 Using custom colors for boxplots

In [38]: import numpy as np

             import matplotlib.pyplot as plt

In [47]: values = np.random.randn(100)

             b = plt.boxplot(values)      #Plotting functions returns a dictionary

             #The key of the dictionary is the name of the graphical elements.

            #such elements will be medians, fliers, whiskers, boxes, and caps.

 #we iterate every graphic primitive that is a part of the boxplot and set its color to black.

            for name, line_list in b.items():                   #b={name:key}

                   for line in line_list:

                          line.set_color('k') #Making a boxplot appear totally black

            plt.show()

Facet Grids分面网格 and Categorical Data类型数据

import seaborn as sns

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

tips = pd.read_csv('../examples/tips.csv')

tips.head()

tips['tip_pct'] = tips['tip'] / (tips['total_bill'] - tips['tip'])

tips.head()

                                         #categorical data                        

sns.factorplot(x='day', y='tip_pct', hue='time', col='smoker', kind='bar', data=tips[tips.tip_pct <1])

 

plt.show()

                                         #categorical data                        

sns.factorplot(x='day', y='tip_pct', row='time', col='smoker', kind='bar', data=tips[tips.tip_pct <1])

 

plt.show()

 

sns.factorplot(x='tip_pct', y='day', kind='box', data=tips[tips.tip_pct<0.5])

plt.show()

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值