matplotlib iterate subplot axis array through single list

前端 未结 6 1293
醉话见心
醉话见心 2020-12-13 04:08

Is there a simple/clean way to iterate an array of axis returned by subplots like

nrow = ncol = 2
a = []
fig, axs = plt.subplots(nrows=nrow, ncols=ncol)
for         


        
6条回答
  •  醉酒成梦
    2020-12-13 04:47

    Matplotlib has its own flatten function on axes.

    Why don't you try following code?

    fig, axes = plt.subplots(2, 3)
    for ax in axes.flat:
        ## do something with instance of 'ax'
    

提交回复
热议问题