调色盘设置

设置调色

color_palette()设置调色盘,返回一个调色盘的颜色列表,默认6种颜色:deep, muted, bright, pastel, dark, colorblind.

seaborn.color_palette(palette=None, n_colors=None, desat=None)
Docstring:
Return a list of colors defining a color palette. Available seaborn palette names:
deep, muted, bright, pastel, dark, colorblind Other options:
name of matplotlib cmap, 'ch:<cubehelix arguments>', 'hls', 'husl',
or a list of colors in any format matplotlib accepts Calling this function with ``palette=None`` will return the current
matplotlib color cycle. Matplotlib palettes can be specified as reversed palettes by appending
"_r" to the name or as "dark" palettes by appending "_d" to the name.
(These options are mutually exclusive, but the resulting list of colors
can also be reversed). This function can also be used in a ``with`` statement to temporarily
set the color cycle for a plot or set of plots. See the :ref:`tutorial <palette_tutorial>` for more information. Parameters
----------
palette: None, string, or sequence, optional
Name of palette or None to return current palette. If a sequence, input
colors are used but possibly cycled and desaturated.
n_colors : int, optional
Number of colors in the palette. If ``None``, the default will depend
on how ``palette`` is specified. Named palettes default to 6 colors,
but grabbing the current palette or passing in a list of colors will
not change the number of colors unless this is specified. Asking for
more colors than exist in the palette will cause it to cycle.
desat : float, optional
Proportion to desaturate each color by. Returns
-------
palette : list of RGB tuples.
Color palette. Behaves like a list, but can be used as a context
manager and possesses an ``as_hex`` method to convert to hex color
codes. See Also
--------
set_palette : Set the default color cycle for all plots.
set_color_codes : Reassign color codes like ``"b"``, ``"g"``, etc. to
colors from one of the seaborn palettes.

Set_palette 设置全局绘图的调色盘。

sns.set_palette(palette, n_colors=None, desat=None, color_codes=False)
Docstring:
Set the matplotlib color cycle using a seaborn palette. Parameters
----------
palette : seaborn color paltte | matplotlib colormap | hls | husl
Palette definition. Should be something that :func:`color_palette`
can process.
n_colors : int
Number of colors in the cycle. The default number of colors will depend
on the format of ``palette``, see the :func:`color_palette`
documentation for more information.
desat : float
Proportion to desaturate each color by.
color_codes : bool
If ``True`` and ``palette`` is a seaborn palette, remap the shorthand
color codes (e.g. "b", "g", "r", etc.) to the colors from this palette.
current_palette = sns.color_palette()
sns.palplot(current_palette) #以水平方向显示颜色条

#默认6种颜色:deep, muted, bright, pastel, dark, colorblind
sns.palplot(sns.color_palette('deep', 8))
sns.palplot(sns.color_palette('muted', 8))
sns.palplot(sns.color_palette('pastel', 8))
sns.palplot(sns.color_palette('bright', 8))
sns.palplot(sns.color_palette('dark', 8))
sns.palplot(sns.color_palette('colorblind', 8))











#常用的其它调色盘
sns.palplot(sns.color_palette('Accent', 8))
sns.palplot(sns.color_palette('Accent_r', 8))
sns.palplot(sns.color_palette('Blues', 8))
sns.palplot(sns.color_palette('Blues_r', 8))
sns.palplot(sns.color_palette('BrBG', 8))
sns.palplot(sns.color_palette('BrBG_r', 8))
sns.palplot(sns.color_palette('BuGn', 8))
sns.palplot(sns.color_palette('BuGn_r', 8))
sns.palplot(sns.color_palette('BuPu', 8))
sns.palplot(sns.color_palette('BuPu_r', 8))

#设置风格
sns.set_style('whitegrid') #设置调色盘的颜色系列
with sns.color_palette('PuBuGn_d'):
plt.subplot(211)
sinplot() sns.set_palette('husl')
plt.subplot(212)
sinplot()

设置亮度和饱和度

sns.hls_palette(n_colors=6, h=0.01, l=0.6, s=0.65)
Docstring:
Get a set of evenly spaced colors in HLS hue space. h, l, and s should be between 0 and 1 Parameters
---------- n_colors : int
number of colors in the palette
h : float
first hue
l : float
lightness
s : float
saturation Returns
-------
palette : seaborn color palette
List-like object of colors as RGB tuples.
sns.husl_palette(n_colors=6, h=0.01, s=0.9, l=0.65)
Docstring:
Get a set of evenly spaced colors in HUSL hue space. h, s, and l should be between 0 and 1 Parameters
---------- n_colors : int
number of colors in the palette
h : float
first hue
s : float
saturation
l : float
lightness Returns
-------
palette : seaborn color palette
List-like object of colors as RGB tuples.
#设置亮度(l)、饱和度(s)
#husl_palette([n_colors, h, s, l])
#hls_palette([n_colors, h, l, s])
sns.palplot(sns.hls_palette(8, l=.9, s=1))
sns.palplot(sns.husl_palette(8, l=.9, s=1))



设置线性颜色

cubehelix_palette()按照线性增长计算,设置颜色。

sns.cubehelix_palette(
n_colors=6,
start=0,
rot=0.4,
gamma=1.0,
hue=0.8,
light=0.85,
dark=0.15,
reverse=False,
as_cmap=False,
)
Docstring:
Make a sequential palette from the cubehelix system. This produces a colormap with linearly-decreasing (or increasing)
brightness. That means that information will be preserved if printed to
black and white or viewed by someone who is colorblind. "cubehelix" is
also available as a matplotlib-based palette, but this function gives the
user more control over the look of the palette and has a different set of
defaults. In addition to using this function, it is also possible to generate a
cubehelix palette generally in seaborn using a string-shorthand; see the
example below. Parameters
----------
n_colors : int
Number of colors in the palette.
start : float, 0 <= start <= 3
The hue at the start of the helix.
rot : float
Rotations around the hue wheel over the range of the palette.
gamma : float 0 <= gamma
Gamma factor to emphasize darker (gamma < 1) or lighter (gamma > 1)
colors.
hue : float, 0 <= hue <= 1
Saturation of the colors.
dark : float 0 <= dark <= 1
Intensity of the darkest color in the palette.
light : float 0 <= light <= 1
Intensity of the lightest color in the palette.
reverse : bool
If True, the palette will go from dark to light.
as_cmap : bool
If True, return a matplotlib colormap instead of a list of colors. Returns
-------
palette or cmap : seaborn color palette or matplotlib colormap
List-like object of colors as RGB tuples, or colormap object that
can map continuous values to colors, depending on the value of the
``as_cmap`` parameter.
#cubehelix_palette()按照线性增长计算,设置颜色
#参数:n_colors 设置颜色个数;start 值区间在0-3,设置开始颜色;rot 设置颜色选择角度;gamma 颜色伽马值,越大越暗;
#dark, light 值区间0-1,颜色深浅;reverse 布尔值,默认为False, 由浅到深
sns.palplot(sns.cubehelix_palette(8, gamma=2))
sns.palplot(sns.cubehelix_palette(8, start=.5, rot=-.75))
sns.palplot(sns.cubehelix_palette(8, start=2, rot=0, dark=0, light=.95, reverse=True))

设置深浅调色盘

#dark_palette(color[, n_colors, reverse,...]) / light_palette(color[, n_colors, reverse, ...])
#颜色深浅 sns.palplot(sns.light_palette('green')) #浅色调色盘,单色选择
sns.palplot(sns.dark_palette('green', reverse=True)) #深色调 sns.palplot(sns.color_palette('Greens')) #cmap为Greens风格
sns.palplot(sns.color_palette('Greens_r'))

设置分散色调

sns.diverging_palette(
h_neg,
h_pos,
s=75,
l=50,
sep=10,
n=6,
center='light',
as_cmap=False,
)
Docstring:
Make a diverging palette between two HUSL colors. If you are using the IPython notebook, you can also choose this palette
interactively with the :func:`choose_diverging_palette` function. Parameters
----------
h_neg, h_pos : float in [0, 359]
Anchor hues for negative and positive extents of the map.
s : float in [0, 100], optional
Anchor saturation for both extents of the map.
l : float in [0, 100], optional
Anchor lightness for both extents of the map.
n : int, optional
Number of colors in the palette (if not returning a cmap)
center : {"light", "dark"}, optional
Whether the center of the palette is light or dark
as_cmap : bool, optional
If true, return a matplotlib colormap object rather than a
list of colors. Returns
-------
palette or cmap : seaborn color palette or matplotlib colormap
List-like object of colors as RGB tuples, or colormap object that
can map continuous values to colors, depending on the value of the
``as_cmap`` parameter. See Also
--------
dark_palette : Create a sequential palette with dark values.
light_palette : Create a sequential palette with light values.
#diverging_palette(h_neg, h_pos, s, l, sep, n, center, as_cmap) 创建分散颜色
#h_neg, h_pos 起始/终止颜色;s 饱和度(0-100);l 亮度(0,100); n 颜色个数;center 默认light (light or dark) sns.palplot(sns.diverging_palette(145, 280, s=85, l=25, n=7))
sns.palplot(sns.diverging_palette(145, 280, s=85, l=25, n=7, center='dark'))

#热图案例
plt.figure(figsize=(8,6))
x = np.arange(25).reshape(5, 5)
cmap = sns.diverging_palette(200, 20, sep=20, as_cmap=True)
sns.heatmap(x, cmap=cmap)

Seaborn调色盘设置的更多相关文章

  1. 图表可视化seaborn风格和调色盘

    seaborn是基于matplotlib的python数据可视化库,提供更高层次的API封装,包括一些高级图表可视化等工具. 使用seaborn需要先安装改模块pip3 install seaborn ...

  2. Opencv基础课必须掌握:滑动条做调色盘 -OpenCV步步精深

    滑动条做调色盘 我们来想一下这个程序需要什么,首先需要一个窗口显示一切=.=(︿( ̄︶ ̄)︿废话一样): 说到调色盘除了画板也就是窗口(默认为黑色),调色就要涉及三种颜色 红色Red(我们用R表示), ...

  3. [原创工具] ListView 调色盘 (Free)

    说明:ListView 调色盘,用来快速调整 ListView Style 的颜色,能导出 Style 本文,及另存 *.style 或 *.fsf 文件. 适用:Android, iOS, Wind ...

  4. Tomcat6 一些调优设置内存和连接数

    Tomcat6 一些调优设置内存和连接数 博客分类: java TomcatJVMLinux应用服务器网络应用  公司的一个服务器使用Tomcat6默认配置,在后台一阵全点击服务器就报废了,查了一下就 ...

  5. jmeter --JVM调优设置

    JMeter用户可根据运行的计算机配置,来适当调整JMeter.bat中的JVM调优设置,如下所示: set HEAP=-Xms512m -Xmx512m set NEW=-XX:NewSize=12 ...

  6. 调色盘canvas

    //调色盘 function draw8(id){ var canvas = document.getElementById(id); var context = canvas.getContext( ...

  7. 微信小程序(mpvue) wx.openSetting 无法调起设置页面

    在开发过程有个需要保存图片/视频到设备相册的业务,so easy~   巴啦啦撸下来了完整功能, wx.saveVideoToPhotosAlbum 会自动调起用户授权,美滋滋~~   btu.... ...

  8. WPF绘制圆形调色盘

    本文使用writeableBitmap类和HSB.RGB模式来绘制圆形的调色盘. 开源项目地址:https://github.com/ZhiminWei/Palette RGB为可见光波段三个颜色通道 ...

  9. Oracle 内存参数调优设置

    Oracle 数据库系统中起到调节作用的参数叫初始化参数,数据库管理员根据实际情况需要适当调整这些 初始化参数以优化Oracle系统. 1 主要系统参数调优介绍 2 系统内存参数的分配 2.1 Ora ...

  10. Etl之HiveSql调优(设置map reduce 的数量)

    前言: 最近发现hivesql的执行速度特别慢,前面我们已经说明了left和union的优化,下面咱们分析一下增加或者减少reduce的数量来提升hsql的速度. 参考:http://www.cnbl ...

随机推荐

  1. 【LeetCode剑指offer#04】包含min函数的栈、栈的压入、弹出序列(辅助栈的应用)

    包含min函数的栈 https://leetcode.cn/problems/bao-han-minhan-shu-de-zhan-lcof/ 定义栈的数据结构,请在该类型中实现一个能够得到栈的最小元 ...

  2. 5分钟教你从爬虫到数据处理到图形化一个界面实现山西理科分数查学校-Python

    5分钟教你从爬虫到数据处理到图形化一个界面实现山西理科分数查学校-Python 引言 在高考结束后,学生们面临的一大挑战是如何根据自己的分数找到合适的大学.这是一个挑战性的任务,因为它涉及大量的数据和 ...

  3. 一文读懂图数据库 Nebula Graph 访问控制实现原理

    摘要:数据库权限管理对大家都很熟悉,然而怎么做好数据库权限管理呢?在本文中将详细介绍 Nebula Graph 的用户管理和权限管理. 本文首发 Nebula Graph 博客:https://neb ...

  4. Netty笔记(2) - 基本实现与异步模型

    示例内容: 服务端监听6668端口 , 客户端连接 并发送信息给服务端 ,服务端收到信息打印 并返回信息给客户端 服务端代码: public class NettyServer { public st ...

  5. 6. JVM本地方法

    1 本地方法 简单地讲,一个Native Method是一个Java调用非Java代码的接囗 一个Native Method是这样一个Java方法:该方法的实现由非Java语言实现,比如C. 这个特征 ...

  6. linux FTP服务搭建,匿名用户访问创建上传文件

    1.安装vsftpd 首先确认本地是否安装vftpd rpm -qa|grep vftpd 安装vsftpd yum install vsftpd 为什么呢??因为写权限问题   root 用户. 这 ...

  7. windows条件下安装linux双系统

    工具: U盘 + rufus(使用烧录进linux镜像) linux镜像 1.windows 管理-压缩卷出一块空闲的磁盘空间(不要使用) 重启电脑   启动项  U盘启动  linux就自动安装,选 ...

  8. 替换掉Chrome浏览器的新标签页【已做好自己的插件,并提供下载】

    https://jingyan.baidu.com/article/fc07f9891b256312ffe5190a.html 我做好了自己的 Chrome 新插件 https://files.cnb ...

  9. day07-Java方法01

    Java方法01 1.什么是方法? Java是语句的集合,它们在一起执行一个功能 方法是解决一类问题的步骤的有序集合 方法包含于类或者对象中 方法在程序中被创建,在其他地方被引用 设计方法的原则:方法 ...

  10. Java取当前时间的一分钟后,并格式化输出

    1.Java1.8 以前 Calendar instance = Calendar.getInstance();//获取当前日期时间 instance.add(Calendar.MINUTE,1);/ ...