栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

初识matplotlib

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

初识matplotlib

学习代码:
import matplotlib.pyplot as plt
import numpy as np

# fig, ax = plt.subplots() # 创建一个包含一个axes的figure
# ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # 绘制图像
# plt.show()

fig = plt.figure() # an empty figure with no Axes 
fig, ax = plt.subplots() # a figure with a single Axes 
fig, axs = plt.subplots(2, 2) # a figure with a 2x2 grid of Axes

# line =plt.plot([1, 2, 3, 4], [1, 4, 2, 3])
# plt.show()

x = np.linspace(0, 2, 100)
fig, ax = plt.subplots()
ax.plot(x, x, label='linear')
ax.plot(x, x**2, label='quadratic')
ax.plot(x, x**3, label='cubic')
ax.set_xlabel('x label')
ax.set_ylabel('y label')
ax.set_title("Simple Plot")
ax.legend()
plt.show()

x = np.linspace(0, 2, 100)
plt.plot(x, x, label='linear')
plt.plot(x, x**2, label='quadratic')
plt.plot(x, x**3, label='cubic')
plt.xlabel('x label')
plt.ylabel('y label')
plt.title("Simple Plot")
plt.legend()
plt.show()

学习了Figure 图窗、Axes 坐标区、Axis 坐标轴、Subplot 子图。

明天继续加油!

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/529890.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号