Travel Tips
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
结构化图表可视化 FacetGrid()
FacetGrid()
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline sns.set_style("ticks") sns.set_context("paper") # 设置风格、尺度 import warnings warnings.filterwarnings('ignore') # 不发出警告
tips = sns.load_dataset("tips") print(tips.head()) # 导入数据 g = sns.FacetGrid(tips, col="time", row="smoker") # 创建一个绘图表格区域,设置好row、col并分组 g.map(plt.hist, "total_bill",alpha = 0.5,color = 'k',bins = 10) # 以total_bill字段数据分别做直方图统计
g = sns.FacetGrid(tips, col="day", size=4, # 图表大小 aspect=.5) # 图表长宽比 g.map(plt.hist, "total_bill", bins=10, histtype = 'step', #'bar', 'barstacked', 'step', 'stepfilled' color = 'k')
g = sns.FacetGrid(tips, col="time", row="smoker") # 创建一个绘图表格区域,设置好row、col并分组 g.map(plt.scatter, "total_bill", "tip", # share{x,y} → 设置x、y数据 edgecolor="w", s = 40, linewidth = 1) # 设置点大小,描边宽度及颜色 g.add_legend() # 添加图例
g = sns.FacetGrid(tips, col="time", hue="smoker") # 创建一个绘图表格区域,设置好col并分组,按hue分类 g.map(plt.scatter, "total_bill", "tip", # share{x,y} → 设置x、y数据 edgecolor="w", s = 40, linewidth = 1) # 设置点大小,描边宽度及颜色 g.add_legend() # 添加图例
attend = sns.load_dataset("attention") print(attend.head()) # 加载数据 g = sns.FacetGrid(attend, col="subject", col_wrap=5, # 设置每行的图表数量 size=1.5) g.map(plt.plot, "solutions", "score", marker="o",color = 'gray',linewidth = 2) # 绘制图表矩阵 g.set(xlim = (0,4), ylim = (0,10), xticks = [0,1,2,3,4], yticks = [0,2,4,6,8,10] ) # 设置x,y轴刻度
Sed ac lorem felis. Ut in odio lorem. Quisque magna dui, maximus ut commodo sed, vestibulum ac nibh. Aenean a tortor in sem tempus auctor
December 4, 2020 at 3:12 pm
Sed ac lorem felis. Ut in odio lorem. Quisque magna dui, maximus ut commodo sed, vestibulum ac nibh. Aenean a tortor in sem tempus auctor
December 4, 2020 at 3:12 pm
Donec in ullamcorper quam. Aenean vel nibh eu magna gravida fermentum. Praesent eget nisi pulvinar, sollicitudin eros vitae, tristique odio.
December 4, 2020 at 3:12 pm
我是 s enim interduante quis metus. Duis porta ornare nulla ut bibendum
Rosie
6 minutes ago