python——使用seaborn画直方图
2017-04-28 19:16
239 查看
# -*- coding: utf-8 -*- import pandas as pd import sys reload(sys) sys.setdefaultencoding('utf8') from pylab import * mpl.rcParams['font.sans-serif'] = ['Microsoft YaHei']#指定默认字体 mpl.rcParams['axes.unicode_minus'] =False # 解决保存图像是负号'-'显示为方块的问题 from sqlalchemy import create_engine import seaborn as sns engine = create_engine('postgresql+psycopg2://username:password@ip:port/databasename') conn = engine.connect() df = pd.read_sql( 'select column,count(1) as number from table group by column', engine).sort() sns.barplot(x=df['column'], y=df["number"], data=df)
效果图如下:
相关文章推荐
- 使用 python 破除网页限制
- python3解析库lxml的安装与基本使用
- ctypes: 使用python调用C编写的动态链接库
- 如何使用Python发送带附件的邮件
- 使用python写的代码行数统计程序
- 使用Python语言设计基于HTML的C语言语法加亮显示程序
- Windows下使用Python通过ODBC/ADO访问数据库
- 关于 python 中使用 lambda 表达式的问题
- 在IE中使用Python作为开发脚本
- 使用Python进行AES加密和解密的示例代码
- python 进行多线程编程,使用Semaphore控制线程数
- 使用python进行小游戏编写
- 在python 中使用正则表达式
- 使用 python 操作 access 数据库
- Python指南--使用Python解释器
- python中使用状态机的简单例子---截取'/x00'之前的字符串
- 使用python发送简单的邮件
- 怎样在wincvs中使用python脚本
- 使用SWIG实现C++扩展Python
- unix下面使用python无法广播