可视化传播PythonCheatSheet (6).pdf
《可视化传播PythonCheatSheet (6).pdf》由会员分享,可在线阅读,更多相关《可视化传播PythonCheatSheet (6).pdf(1页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Python For Data Science Cheat SheetSeabornLearn Data Science Interactively at www.DataC Statistical Data Visualization With SeabornDataCampLearn Python for Data Science Interactively Figure Aesthetics DataThe Python visualization library Seaborn is based on matplotlib and provides a high-level inter
2、face for drawing attractive statistical graphics.Make use of the following aliases to import the libraries:The basic steps to creating plots with Seaborn are:1.Prepare some data 2.Control figure aesthetics 3.Plot with Seaborn 4.Further customize your plot import pandas as pd import numpy as np unifo
3、rm_data=np.random.rand(10,12)data=pd.DataFrame(x:np.arange(1,101),y:np.random.normal(0,4,100)import matplotlib.pyplot as plt import seaborn as sns Plotting With Seaborn import matplotlib.pyplot as plt import seaborn as sns tips=sns.load_dataset(tips)sns.set_style(whitegrid)g=sns.lmplot(x=tip,y=total
4、_bill,data=tips,aspect=2)g=(g.set_axis_labels(Tip,Total bill(USD).set(xlim=(0,10),ylim=(0,100)plt.title(title)plt.show(g)Step 4Step 2Step 1Step 5Step 31 titanic=sns.load_dataset(titanic)iris=sns.load_dataset(iris)Seaborn also offers built-in data sets:23 Further Customizations4 Show or Save Plot sns
5、.set()(Re)set the seaborn default sns.set_style(whitegrid)Set the matplotlib parameters sns.set_style(ticks,Set the matplotlib parameters xtick.major.size:8,ytick.major.size:8)sns.axes_style(whitegrid)Return a dict of params or use with with to temporarily set the styleAxis Grids f,ax=plt.subplots(f
6、igsize=(5,6)Create a figure and one subplot plt.title(A Title)Add plot title plt.ylabel(Survived)Adjust the label of the y-axis plt.xlabel(Sex)Adjust the label of the x-axis plt.ylim(0,100)Adjust the limits of the y-axis plt.xlim(0,10)Adjust the limits of the x-axis plt.setp(ax,yticks=0,5)Adjust a p
7、lot property plt.tight_layout()Adjust subplot params plt.show()Show the plot plt.savefig(foo.png)Save the plot as a figure plt.savefig(foo.png,Save transparent figure transparent=True)sns.regplot(x=sepal_width,Plot data and a linear regression y=sepal_length,model fit data=iris,ax=ax)g.despine(left=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 可视化传播PythonCheatSheet 6 可视化 传播 PythonCheatSheet
限制150内