seaborn drawing tools
It is matplotlib development, easy to draw more sophisticated graphics, compatible with pandas and numpy and other data structures
are three ways to draw: plt.style.use ( 'seabon'), sns.set (), using seaborn function
import seaborn as sns
plt.style.use(‘seabon’)
Adding graphics directly in front of the original use matplotlib drawn the statement, the graphics automatically appear as a grid like background
plt.style.use('seaborn')
#防止中文乱码和图形中文显示
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
data=pd.read_csv('my_csv_date.csv',encoding='gbk')
plt.bar(data.顺序1.head(5),height=data.属1.head(5),color='c',)
plt.show()
sns.set()
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib as mpl
sns.set(style='darkgrid',context='notebook',font_scale=1.2)
#防止中文乱码和图形中文显示
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
data=pd.read_csv('my_csv_date.csv',encoding='gbk')
plt.bar(data.顺序1.head(5),height=data.属1.head(5),color='c',)
plt.show()
sns.barplot () to create a histogram
sns.barplot(x='顺序1',y='属2',data=data,color='c')
plt.show()
sns.barplot(x='属2',y='顺序1',data=data,color='c',orient='h')
plt.show()
Direction data contains characters 'order', '2 genus' column, otherwise an error, and automatically adds x, y labels, Orient graph showing the
add text to each column
data=pd.read_csv('my_csv_date.csv',encoding='gbk')
sns.barplot(x='顺序1',y='属2',data=data,color='c')
for x,y in enumerate(data.属2):
plt.text(x,y+1,'%s万元'% round(y,1),ha='center',fontsize=15)
plt.show()