【问题标题】:plot two figures in one line in ipython notebook在 ipython 笔记本中的一行中绘制两个数字
【发布时间】:2016-05-20 08:36:25
【问题描述】:

我只是使用ipython 中的内联来绘制数字

%matplotlib inline

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

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

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

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

【问题讨论】:

    标签: python ipython figure


    【解决方案1】:
    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)
    

    【讨论】:

      【解决方案2】:

      这是example

      def imshow_pair(image_pair, titles=('', ''), figsize=(10, 5), **kwargs):
          fig, axes = plt.subplots(ncols=2, figsize=figsize)
          for ax, img, label in zip(axes.ravel(), image_pair, titles):
              ax.imshow(img, **kwargs)
              ax.set_title(label)
      

      【讨论】:

        【解决方案3】:

        尝试使用 matplotlib.pyplot.subplot() 在一个图中绘制多个子图。

        【讨论】:

          猜你喜欢
          • 2023-03-21
          • 1970-01-01
          • 1970-01-01
          • 2015-10-15
          • 2015-11-10
          • 2015-06-17
          • 1970-01-01
          • 2015-07-19
          • 1970-01-01
          相关资源
          最近更新 更多