Python经典画图模版:散点图、平滑曲线图、分段曲线图、雷达图

本文介绍了Python画图模版,包括最简单的曲线和散点图,需要自行填充数据的分段曲线图,以及雷达图的绘制。适合初学者和需要进阶绘图技巧的开发者。
摘要由CSDN通过智能技术生成

在这里插入图片描述

一、最简单的模版(曲线、散点)。

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()

在这里插入图片描述

import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16], 'ro')#x=[1,2,3,4],y=[1,4,9,16],'ro'表示红色的圆点
#axis接收的list参数表示:[xmin, xmax, ymin, ymax] 
plt.axis([0, 6, 0, 20])#设置x、y轴的长度,x轴为[0,6],y轴为[0,20]
plt.show()

在这里插入图片描述

import numpy as np
import matplotlib.pyplot as plt
# 以0.2为间隔均匀采样
t = np.arange(0., 5., 0.2)
#查看t的值

# 'r--':红色的需要;'bs':蓝色方块;'g^':绿色三角
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
plt.show()

在这里插入图片描述

二、微微复杂的模版,需要自己填写列表数据,注意x轴与y轴数据个数要相同

import numpy as np
from matplotlib import pyplot as plt
from scipy.interpolate import make_interp_spline

font1 = {
   'family' : 'DejaVu Sans',
'weight' : 'normal',
'size'   : 20,
}

x = np.array([0, 12,25, 36,50,62,75,84,100])
y = np.array([999.84,999.5, 997.05, 993.69,988.04,982.16,974.24,969.26,958.36])
x_smooth = np.linspace(x.min(), x.max(), 300)
y_smooth = make_interp_spline(x, y)(x_smooth)
plt.xlabel(u'T/℃',font1)#fill the meaning of X axis
plt.ylabel(u'ρ/kg*m-3',font1)#fill the meaning of Y axis
plt.title(u'T-ρ&#
  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值