亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python使用add_subplot與subplot畫子圖操作示例

 更新時(shí)間:2018年06月01日 14:20:30   作者:有一種宿命叫無(wú)能為力  
這篇文章主要介紹了Python使用add_subplot與subplot畫子圖操作,涉及Python使用matplotlib模塊進(jìn)行圖形繪制的相關(guān)操作技巧,需要的朋友可以參考下

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

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

Matplotlib對(duì)象簡(jiǎn)介

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

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

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

#!/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é)果:

更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python數(shù)學(xué)運(yùn)算技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python編碼操作技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python入門與進(jìn)階經(jīng)典教程》及《Python文件與目錄操作技巧匯總

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

相關(guān)文章

最新評(píng)論