Skip to main content
 首页 » 编程设计

python之在 ipython 笔记本中在一行中绘制两个数字

2025年05月04日26小虾米

我只是使用 ipython 中的内联来绘制图形

%matplotlib inline 

但是,由于我想在笔记本中绘制数千个数字并同时比较每两个数字,但是 ipython 只给我这个 two figure , 一个在另一个下面。

我就想知道,怎么把这两张图排成一行。那是一个在另一个的右边?

而且,subplot 不会成为我的选择,因为我只是使用包中的 functions 来绘制这两个图。

ee.daily_plot(2) 
ee.hourly_plot(2) 

请您参考如下方法:

import matplotlib.pyplot as plt 
import numpy as np 
 
x = np.arange(10) 
y = np.arange(10) 
z = np.arange(10)**2 
 
nrows = 1 
ncols = 2 
fig = plt.figure(figsize=(10, 5)) 
 
ax = fig.add_subplot(nrows, ncols, 1) 
ax.plot(x, y) 
 
ax = fig.add_subplot(nrows, ncols, 2) 
ax.plot(x, z)