文献图复现-方块图-python

来源

Guo, W., et al., Vegetation can strongly regulate permafrost degradation at its southern edge through changing surface freeze-thaw processes. Agricultural and Forest Meteorology, 2018. 252: p. 10-17.
在这里插入图片描述

解释

用数字表示矩阵内包含的点数,颜色表示另外一个数据。

复现图

在这里插入图片描述

复现代码(python)

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.pyplot import MultipleLocator

#------数据需要先自行准备好------
x = (0,80,160,200,200,240)
y = (1.5,2.25,2,3,1.5,1.5)
c = (63,78,94,85,64,108)
t = (4,9,8,6,3,7)
#------数据准备------

fig = plt.figure()
fig, ax = plt.subplots(1, 1,figsize=(8,7),dpi=300)

#------xy轴刻度间隔-----
x_major_locator=MultipleLocator(80)
y_major_locator=MultipleLocator(0.5)
ax.xaxis.set_major_locator(x_major_locator)
ax.yaxis.set_major_locator(y_major_locator)

#------点中心位置------
x = [a + 20 for a in x]
y = [a + 0.125 for a in y]

#------绘图------
cm = plt.cm.get_cmap('rainbow',7) #分为7级
sc = plt.scatter(x, y, marker=',',s=580,
                 c=c, vmin=50, vmax=120, cmap=cm)
#-----加上数字标签------
for i in range(len(x)):
    ax.text(x[i], y[i]-0.02, t[i], size=20, va="center", ha="center")
    
ax.set(xlim=(0,560),ylim=(0.5,4))
plt.colorbar(sc)

plt.show()

参考

  1. scatter设置颜色渐变
  2. 定义图表中的色彩
  3. 数组里的每一个元素都加1
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

撼沧

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值