欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python可視化之seborn圖形外觀設(shè)置

 更新時間:2022年03月03日 08:27:20   作者:?pythonic生物人  
這篇文章主要介紹了Python可視化之seborn圖形外觀設(shè)置,本文介紹seaborn圖形外觀、圖形縮放設(shè)置.具有一的的參考價值,需要的小伙伴可以參考一下

本文將了解什么?

1、設(shè)置背景風格

  •  使用set_style設(shè)置圖形背景風格
  •  不同子圖使用不同背景風格 
  •  自定義背景風格  

2、設(shè)置外框(脊柱)
3、圖形縮放
4、同時設(shè)置背景|圖形縮放

1、設(shè)置背景風格

使用set_style設(shè)置圖形背景風格

#seaborn包含5中背景風格darkgrid, whitegrid, dark, white, ticks,默認為dark
#set_style()修改風格,以下展示5種風格差異
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
for i in list('darkgrid, whitegrid, dark, white, ticks'.split(', ')):
? ? sns.set_style(style='%s'%i)
? ? plt.figure()
? ? plt.plot(range(10),[i+1 for i in range(10)])?
? ? plt.title('%s'%i)

不同子圖使用不同背景風格

axes_style() 結(jié)合with

f = plt.figure(figsize=(6, 6))
gs = f.add_gridspec(2, 2)

with sns.axes_style("darkgrid"):
? ? ax = f.add_subplot(gs[0, 0])
? ? plt.plot(range(10),[i+1 for i in range(10)])

with sns.axes_style("white"):
? ? ax = f.add_subplot(gs[0, 1])
? ? plt.plot(range(10),[i+1 for i in range(10)])

with sns.axes_style("ticks"):
? ? ax = f.add_subplot(gs[1, 0])
? ? plt.plot(range(10),[i+1 for i in range(10)])

with sns.axes_style("whitegrid"):
? ? ax = f.add_subplot(gs[1, 1])
? ? plt.plot(range(10),[i+1 for i in range(10)])

f.tight_layout()

自定義背景風格

sns.axes_style('darkgrid')#輸出'darkgrid'默認配置

{'figure.facecolor': 'white',
?'axes.labelcolor': '.15',
?'xtick.direction': 'out',
?'ytick.direction': 'out',
?'xtick.color': '.15',
?'ytick.color': '.15',
?'axes.axisbelow': True,
?'grid.linestyle': '-',
?'text.color': '.15',
?'font.family': ['sans-serif'],
?'font.sans-serif': ['Arial',
? 'DejaVu Sans',
? 'Liberation Sans',
? 'Bitstream Vera Sans',
? 'sans-serif'],
?'lines.solid_capstyle': 'round',
?'patch.edgecolor': 'w',
?'patch.force_edgecolor': True,
?'image.cmap': 'rocket',
?'xtick.top': False,
?'ytick.right': False,
?'axes.grid': True,
?'axes.facecolor': '#EAEAF2',
?'axes.edgecolor': 'white',
?'grid.color': 'white',
?'axes.spines.left': True,
?'axes.spines.bottom': True,
?'axes.spines.right': True,
?'axes.spines.top': True,
?'xtick.bottom': False,
?'ytick.left': False}
sns.set_style("darkgrid", {"axes.facecolor": "pink"})#修改背景色
plt.plot(range(10),[i+1 for i in range(10)])

2、設(shè)置外框(脊柱)

seaborn.despine

plt.plot(range(10),[i+1 for i in range(10)])
sns.despine(fig=None, ax=None,?
? ? ? ? ? ? top=True, right=True, left=False, bottom=False, #上,右,左,下外框開關(guān)
? ? ? ? ? ? offset=None, trim=False
? ? ? ? ? ?)

3、圖形縮放

plotting_context() set_context()

#seaborn包含4模式可選:paper,notebook,talk,poster,默認為notebook
#set_context()修改模式,以下展示4種風格差異
for i in list('paper,notebook,talk,poster'.split(',')):
? ? sns.set_context(context='%s'%i)
? ? plt.figure(dpi=80)
? ? plt.plot(range(10),[i+1 for i in range(10)])?
? ? plt.title('%s'%i)

4、同時設(shè)置背景|圖形縮放

set()

sns.set(context='notebook', #設(shè)置縮放
? ? ? ? style='darkgrid', #設(shè)置背景風格
? ? ? ? palette='deep', #設(shè)置colormap
? ? ? ? font='sans-serif', font_scale=1, color_codes=True, rc=None)

到此這篇關(guān)于Python可視化之seborn圖形外觀設(shè)置的文章就介紹到這了,更多相關(guān)seborn圖形外觀設(shè)置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論