【python】Matplotlib作图常用marker类型、线型和颜色
python作图中常常会考虑用什么颜色、marker、线型,这个资料查了又查,所以自己总结在这个地方,以便常用。
一、常用marker表示
1.普通marker
这类普通marker直接marker ='^'就可以用了

2.高级marker
这类高级marker使用marker ='$\circledR$'来调用
可以显示的形状 marker名称
ϖ \varpi
ϱ \varrho
ς \varsigma
ϑ \vartheta
ξ \xi
ζ \zeta
Δ \Delta
Γ \Gamma
Λ \Lambda
Ω \Omega
Φ \Phi
Π \Pi
Ψ \Psi
Σ \Sigma
Θ \Theta
Υ \Upsilon
Ξ \Xi
℧ \mho
∇ \nabla
ℵ \aleph
ℶ \beth
ℸ \daleth
ℷ \gimel
/ /
[ [
⇓ \Downarrow
⇑ \Uparrow
‖ \Vert
↓ \downarrow
⟨ \langle
⌈ \lceil
⌊ \lfloor
⌞ \llcorner
⌟ \lrcorner
⟩ \rangle
⌉ \rceil
⌋ \rfloor
⌜ \ulcorner
↑ \uparrow
⌝ \urcorner
\vert
{ \{
\|
} \}
] ]
|
⋂ \bigcap
⋃ \bigcup
⨀ \bigodot
⨁ \bigoplus
⨂ \bigotimes
⨄ \biguplus
⋁ \bigvee
⋀ \bigwedge
∐ \coprod
∫ \int
∮ \oint
∏ \prod
∑ \sum
3.自定义marker
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] # 用于显示中文
plt.rcParams['axes.unicode_minus'] = False # 用于显示中文
plt.figure(dpi=200)
#常规marker使用
plt.plot([1,2,3],[1,2,3],marker=4, markersize=15, color='lightblue',label='常规marker')
plt.plot([1.8,2.8,3.8],[1,2,3],marker='2', markersize=15, color='#ec2d7a',label='常规marker')
#非常规marker使用
#注意使用两个$符号包围名称
plt.plot([1,2,3],[4,5,6],marker='$\circledR$', markersize=15, color='r', alpha = 0.5 ,label='非常规marker')
plt.plot([1.5,2.5,3.5],[1.25,2.1,6.5],marker='$\heartsuit$', markersize=15, color='#f19790', alpha=0.5,label='非常规marker')
plt.plot([1,2,3],[2.5,6.2,8],marker='$\clubsuit$', markersize=15, color='g', alpha=0.5,label='非常规marker')
#自定义marker
plt.plot([1.2,2.2,3.2],[1,2,3],marker='$666$', markersize=15, color='#2d0c13',label='自定义marker')
plt.legend(loc='upper left')
for i in ['top','right']:
plt.gca().spines[i].set_visible(False)
作图结果为:

二、常用线型
1.字符型linestyle
共有四种:
linestyle_str = [
('solid', 'solid'), # Same as (0, ()) or '-';solid’, (0, ()) , '-'三种都代表实线。
('dotted', 'dotted'), # Same as (0, (1, 1)) or '.'
('dashed', 'dashed'), # Same as '--'
('dashdot', 'dashdot')] # Same as '-.'
2.元组型linestyle
可以通过修改元组中的数字来呈现出不同的线型,因此可以构造出无数种线型。
linestyle_tuple = [
('loosely dotted', (0, (1, 10))),
('dotted', (0, (1, 1))),
('densely dotted', (0, (1, 2))), ('loosely dashed', (0, (5, 10))),
('dashed', (0, (5, 5))),
('densely dashed', (0, (5, 1))), ('loosely dashdotted', (0, (3, 10, 1, 10))),
('dashdotted', (0, (3, 5, 1, 5))),
('densely dashdotted', (0, (3, 1, 1, 1))), ('dashdotdotted', (0, (3, 5, 1, 5, 1, 5))),
('loosely dashdotdotted', (0, (3, 10, 1, 10, 1, 10))),
('densely dashdotdotted', (0, (3, 1, 1, 1, 1, 1)))]
线型使用代码:
import matplotlib.pyplot as plt
plt.figure(dpi=120)
#字符型linestyle使用方法
plt.plot([1,2,3],[1,2,13],linestyle='dotted', color='#1661ab', linewidth=5, label='字符型线型:dotted')
#元组型lintstyle使用方法
plt.plot([0.8,0.9,1.5],[0.8,0.9,21.5],linestyle=(0,(3, 1, 1, 1, 1, 1)), color='#ec2d7a', linewidth=5, label='元组型线型:(0,(3, 1, 1, 1, 1, 1)')
for i in ['top','right']:
plt.gca().spines[i].set_visible(False)
#自定义inestyle
plt.plot([1.5,2.5,3.5],[1,2,13],linestyle=(0,(1,2,3,4,2,2)), color='black', linewidth=5, label='自定义线型:(0,(1,2,3,4,2,2)))')
plt.plot([2.5,3.5,4.5],[1,2,13],linestyle=(2,(1,2,3,4,2,2)), color='g', linewidth=5, label='自定义线型:(1,(1,2,3,4,2,2)))')
plt.legend()
作图结果为:

3.元组型详解
上图中线型(0,(1,2,3,4,2,2))每个数字是什么意思?理解每个数字的意思就可以自定义线型了。

第一个0的意义,比较黑色和绿色线型即可知道
1,2 第一小段线宽1磅,第一和第二段之间距离2磅
3,4 第二小段线宽3磅,第二和第三段之间距离4磅
2,2 第三小段线宽2磅,第三和第四段之间距离2磅
三、常用颜色




装了seaborn扩展的话,在字典seaborn.xkcd_rgb中包含所有的xkcd crowdsourced color names。

以上部分内容参考:pythonic生物人,链接:https://www.jianshu.com/p/7543b925bdb8
【python】Matplotlib作图常用marker类型、线型和颜色的更多相关文章
- 【python】Matplotlib作图中有多个Y轴
在作图过程中,需要绘制多个变量,但是每个变量的数量级不同,在一个坐标轴下作图导致曲线变化很难观察,这时就用到多个坐标轴.本文除了涉及多个坐标轴还包括Axisartist相关作图指令.做图中label为 ...
- Python离线断网情况下安装numpy、pandas和matplotlib等常用第三方包
联网情况下在命令终端CMD中输入“pip install numpy”即可自动安装,pandas和matplotlib同理一样方法进行自动安装. 工作的电脑不能上外网,所以不能通过直接输入pip命令来 ...
- Python - matplotlib 数据可视化
在许多实际问题中,经常要对给出的数据进行可视化,便于观察. 今天专门针对Python中的数据可视化模块--matplotlib这块内容系统的整理,方便查找使用. 本文来自于对<利用python进 ...
- Python 数据分析中常用的可视化工具
Python 数据分析中常用的可视化工具 1 Matplotlib 用于创建出版质量图表的绘图工具库,目的是为 Python 构建一个 Matlab 式的绘图接口. 1.1 安装 Anaconada ...
- 【转载】Python编程中常用的12种基础知识总结
Python编程中常用的12种基础知识总结:正则表达式替换,遍历目录方法,列表按列排序.去重,字典排序,字典.列表.字符串互转,时间对象操作,命令行参数解析(getopt),print 格式化输出,进 ...
- python笔记之常用模块用法分析
python笔记之常用模块用法分析 内置模块(不用import就可以直接使用) 常用内置函数 help(obj) 在线帮助, obj可是任何类型 callable(obj) 查看一个obj是不是可以像 ...
- Python编程中常用的12种基础知识总结
原地址:http://blog.jobbole.com/48541/ Python编程中常用的12种基础知识总结:正则表达式替换,遍历目录方法,列表按列排序.去重,字典排序,字典.列表.字符串互转,时 ...
- python基础(常用内容)
python基础(常用内容) 机器数: 一个数在计算机中的二进制表示形式就是机器数. 例如: +3用机器数表示就用<00000011>表示 -3用机器数表示就用<10000011&g ...
- 十八. Python基础(18)常用模块
十八. Python基础(18)常用模块 1 ● 常用模块及其用途 collections模块: 一些扩展的数据类型→Counter, deque, defaultdict, namedtuple, ...
随机推荐
- 【转】Setting up SDL Extension Libraries on MinGW
FROM:http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/windows ...
- 【转】Setting up SDL 2 on MinGW
FROM: http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/mingw/index.php Setting up SDL 2 on MinG ...
- 寻找性能更优秀的动态 Getter 和 Setter 方案
反射获取 PropertyInfo 可以对对象的属性值进行读取或者写入,但是这样性能不好.所以,我们需要更快的方案. 方案说明 就是用表达式编译一个 Action<TObj,TValue> ...
- JS数组去重的9种方法(包括去重NaN和复杂数组类型)
其实网上已经有很多js数组的去重方法,但是我看了很多篇并自己通过代码验证,发现都有一些缺陷,于是在研究多篇代码之后,自己总结了9种方法,如果有哪里不对请及时纠正我哈~ 转载请表明出处 测试代码 let ...
- 搞微服务用阿里开源的 Nacos 真香啊!
本文适合有 Java 基础知识的人群 本文作者:HelloGitHub-秦人 HelloGitHub 推出的<讲解开源项目>系列,今天给大家带来一款开源 Java 版可以实现动态服务发现, ...
- form表单ajax提交
这里下面有两种 第一种是form表单里面添加了数据,并且含有上传的图片,第二种是from表单中不含有图片 只有普通数据 第一种form表单中包含有图片的类型: <form method=&q ...
- C# type对象
新建控制台应用程序 新建一个类 class MyClass { private int id; private int age; public int numb; public string Name ...
- 【JVM第七篇】执行引擎
写在前面的话:本文是在观看尚硅谷JVM教程后,整理的学习笔记.其观看地址如下:尚硅谷2020最新版宋红康JVM教程 执行引擎是Java虚拟机中的核心组成部分. 执行引擎的作用就是解析虚拟机字节码指令, ...
- binary hacks读数笔记(readelf基本命令)
一.首先对readelf常用的参数进行简单说明: readelf命令是Linux下的分析ELF文件的命令,这个命令在分析ELF文件格式时非常有用,下面以ELF格式可执行文件test为例详细介绍: 1. ...
- linux定时任务(crontab和at)
查看定时任务:crontab -l [root@localhost test]# crontab -l no crontab for root 创建编辑定时任务:crontab -e [root@lo ...