从csv循环创建子图

嗨,我正在使用matplotlib从不同的csv文件创建多个图。我能够将图创建为另存为单独jpeg的单独图形。我想将所有图形合并在一页和一个文件中。我写的代码如下

path='xxxxx'
for filename in os.listdir(path):
    if fnmatch.fnmatch(filename,'*.csv'):
        print(filename)
        dataframe= pd.read_csv(filename)
        dataframe["A"] = pd.to_datetime(dataframe["xxxxx"].astype('object'),errors='coerce').iloc[1:1441]

        ax=dataframe.plot(x="A",y="BBBBB",figsize=(60,20),kind='area',fontsize=60,legend=False)
        ax.xaxis.set_major_formatter(DateFormatter("%Y-%m-%d %I:%M %p"))

        ax.set_ylabel("Number of Steps",fontweight='bold')
        ax.set_ylim(top=80)
        ax.set_xlabel("Time",fontweight='bold')
        ax.set_title('Graph for case_{}:'.format(filename),fontweight='bold')

        ax.grid(True)
        ax.xaxis.set_ticks_position('bottom')
        plt.tight_layout()
        plt.savefig('{}_.jpeg'.format(filename),dpi = 300)
ermaotd 回答:从csv循环创建子图

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2983802.html

大家都在问