解决seaborn在pycharm中绘图不出图的问题

yipeiwu_com6年前Python基础

如下所示:

<span style="font-size:18px;">
</span>
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

np.random.seed(sum(map(ord, 'axis_grids')))
tips = sns.load_dataset('tips')
tips.head()

# 将FacetGrid实例化出来
g = sns.FacetGrid(tips, col='time')
g.map(plt.hist, 'tip')

# 散点图把数据描绘出来 alpha透明程度,越小越透明
g = sns.FacetGrid(tips, col='sex', hue='smoker')
g.map(plt.scatter, 'total_bill', 'tip', alpha=.1)
g.add_legend()
plt.show()

在代码最后加上plt.show( )即可。

以上这篇解决seaborn在pycharm中绘图不出图的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python中多层嵌套列表的拆分方法

场景:有一个多层嵌套的列表如:[[23],[3,3],[22,22],1,123,[[123,a],2]] 拆分成: def splitlist(list): ''' 现...

python基于SMTP协议发送邮件

本文实例为大家分享了python基于SMTP协议发送邮件的具体代码,供大家参考,具体内容如下 #!/usr/bin/env python # -*- coding: utf-8 -*...

python 反向输出字符串的方法

python 反向输出字符串的方法 方法一:采用列表reversed函数 class Solution(object): def reverse_string(self, s):...

Python中endswith()函数的基本使用

函数:endswith() 作用:判断字符串是否以指定字符或子字符串结尾,常用于判断文件类型 相关函数:判断字符串开头 startswith() 一、函数说明 语法:string.en...

Python回文字符串及回文数字判定功能示例

本文实例讲述了Python回文字符串及回文数字判定功能。分享给大家供大家参考,具体如下: 所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的。回文数字也是如此。 pyth...