How do I get multiple subplots in matplotlib?

后端 未结 6 860
自闭症患者
自闭症患者 2020-11-22 06:49

I am a little confused about how this code works:

fig, axes = plt.subplots(nrows=2, ncols=2)
plt.show()

How does the fig, axes work in this

6条回答
  •  孤街浪徒
    2020-11-22 07:01

    Go with the following if you really want to use a loop. Nobody has actually answered how to feed data in a loop:

    def plot(data):
        fig = plt.figure(figsize=(100, 100))
        for idx, k in enumerate(data.keys(), 1):
            x, y = data[k].keys(), data[k].values
            plt.subplot(63, 10, idx)
            plt.bar(x, y)  
        plt.show()
    

提交回复
热议问题