日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

python画子图_Python使用add_subplot与subplot画子图操作示例

發(fā)布時(shí)間:2025/3/11 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python画子图_Python使用add_subplot与subplot画子图操作示例 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

本文實(shí)例講述了Python使用add_subplot與subplot畫子圖操作。分享給大家供大家參考,具體如下:

子圖:就是在一張figure里面生成多張子圖。

Matplotlib對象簡介

FigureCanvas? 畫布

Figure??????? 圖

Axes????????? 坐標(biāo)軸(實(shí)際畫圖的地方)

注意,pyplot的方式中plt.subplot()參數(shù)和面向?qū)ο笾械腶dd_subplot()參數(shù)和含義都相同。

使用面向?qū)ο蟮姆绞?/p>

#!/usr/bin/python

#coding: utf-8

import numpy as np

import matplotlib.pyplot as plt

x = np.arange(0, 100)

fig = plt.figure()

ax1 = fig.add_subplot(221)

ax1.plot(x, x)

ax2 = fig.add_subplot(222)

ax2.plot(x, -x)

ax3 = fig.add_subplot(223)

ax3.plot(x, x ** 2)

ax4 = fig.add_subplot(224)

ax4.plot(x, np.log(x))

plt.show()

pyplot的方式

#!/usr/bin/python

#coding: utf-8

import numpy as np

import matplotlib.pyplot as plt

x = np.arange(0, 100)

plt.subplot(221)

plt.plot(x, x)

plt.subplot(222)

plt.plot(x, -x)

plt.subplot(223)

plt.plot(x, x ** 2)

plt.subplot(224)

plt.plot(x, np.log(x))

plt.show()

運(yùn)行結(jié)果:

希望本文所述對大家Python程序設(shè)計(jì)有所幫助。

總結(jié)

以上是生活随笔為你收集整理的python画子图_Python使用add_subplot与subplot画子图操作示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。