python图 链接矩阵法_Python | 矩阵子图

python图 链接矩阵法

Many times while plotting a figure, we have to compare different functions simultaneously. Then we do have the option to plot in a single figure but this is helpful only for a limited number of functions. If there are a greater number of functions, then plotting in the same figure turns out to be messy. Therefore, matplotlib provides a feature of subploting in which we can plot more than one plot in one figure with more than one graph. Matrix Subplotting is a type of subplotting when we have subplots in a matrix format and a large number of figures can be compared. For example, population data of multiple countries.

绘制图形很多时候,我们必须同时比较不同的功能。 然后,我们确实可以选择绘制单个图形,但这仅对有限数量的功能有用。 如果有更多的功能,则在同一图中绘制会变得很混乱。 因此,matplotlib提供了细分功能,其中我们可以在一个图形中绘制多个图形,并在多个图形中绘制图形。 当我们具有矩阵格式的子图并且可以比较大量图形时,矩阵子图就是一种子图。 例如,多个国家的人口数据。

Python | Matrix Subplot (1)

Syntax:

句法:

#Matrix plotting in a one figure
plt.figure()

plt.subplot(2, 3, 1)
#plt.title('1')

plt.subplot(2, 3, 2)
#plt.title('2')

plt.subplot(2, 3, 3)
#plt.title('3')

plt.subplot(2, 3, 4)
#plt.title('4')

plt.subplot(2, 3, 5)
#plt.title('5')

plt.subplot(2, 3, 6)
#plt.title('6')

plt.show()

Python | Matrix Subplot (2)

矩阵子图的Python代码 (Python code for matrix subplot)

# Data Visualization using Python
# Matrix Subploting
import numpy as np
import matplotlib.pyplot as plt

x = np.arange(50)

# Example 1 : Default Subplot
plt.figure(figsize=(20,15))
plt.title('MAtrix Subploting')

plt.subplot(2, 3, 1)
plt.plot(x, np.random.randint(0,50,50))
plt.title('1')

plt.subplot(2, 3, 2)
plt.plot(x, np.random.randint(0,50,50), 'r--')
plt.title('2')

plt.subplot(2, 3, 3)
plt.plot(x, np.random.randint(0,50,50), 'b-')
plt.title('3')

plt.subplot(2, 3, 4)
plt.plot(x, np.random.randint(0,50,50), '.-')
plt.title('4')

plt.subplot(2, 3, 5)
plt.plot(x, np.random.randint(0,50,50), '.')
plt.title('5')

plt.subplot(2, 3, 6)
plt.plot(x, np.random.randint(0,50,50), 'g')
plt.title('6')

plt.show()

Output:

输出:

Output is as figure


翻译自: https://www.includehelp.com/python/matrix-subplot.aspx

python图 链接矩阵法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值