sns.lineplot, and style settings sns.set ()
import os
import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
os.chdir(r'C:\Users\MAR\Desktop\test')
#表示带坐标标签的,
sns.set(style='ticks',context='notebook')
#网格显示
# sns.set(style='darkgrid',context='notebook')
#解决中文乱码问题
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
my_data=pd.read_csv('my_csv_date.csv',encoding='gbk')
sns.lineplot(x='年份',y='总收入',data=my_data,lw=2,color='red')
plt.xticks(range(1992,2005,1),range(1992,2005,1),rotation=45)
plt.show()
** data using the 'year columns' and the 'total data' column **
Regression Figure
#fit_reg:是否拟合,scatter_kws:表示散点参数
sns.lmplot(x='x1',y='总收入',data=my_data,legend_out=False,\
markers='o',fit_reg=True,aspect=1.3,height=8,scatter_kws={'s':20,'facecolor':'red'})
plt.show()
sns.countplot
Draw a separate histogram data
This method of drawing a histogram, just counting the number of parameter index x appears as a height, and other irrelevant data columns
my_data=pd.read_csv('my_csv_date.csv',encoding='gbk')
sns.countplot(x='地区',data=my_data)
plt.show()
Data for the
graphical data using Datafram direct drawing, and the same data above, the following shows the different
my_data[0:6]['地区'].value_counts().plot(kind='bar')
plt.show()
A histogram of the multi-type data
sns.set () in, font_scale set the font ratio, palette overall color style
import os
import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
os.chdir(r'C:\Users\MAR\Desktop\test')
# #表示带坐标标签的,context设置元素缩放,一般不动
sns.set(style='darkgrid',context='notebook',font_scale=1.2,palette='colorblind')
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
my_data=pd.read_csv('my_csv_date.csv',encoding='gbk')
sns.countplot(x='地区',hue='交通方式',data=my_data)
plt.legend(loc=(1.1,0.6),title='交通方式')
plt.show()
data