简体   繁体   English

如何在同一个 plot 上将 plot 多个 CSV 文件作为箱线图

[英]How to plot multiple CSV files as a boxplot on the same plot

I have 13 different saved CSV files in a folder and each file contains just one column of data (i previously saved these separately from a larger dataset using python having calculated what I needed to), I would like to plot each of these files as 13 different boxplots on the same plot.我在一个文件夹中保存了 13 个不同的 CSV 文件,每个文件仅包含一列数据(我以前使用 python 将这些文件与更大的数据集分开保存,并计算了我需要的内容),我想将这些文件中的每个 Z32FA6E1B78A9D4028953E6056C同一 plot 上的不同箱线图。

I am quite new to python and I'm familiar with matplotlib, so far I know how to plot each of these files individually but of course, I would like them to be plotted next to each other so I can better compare and visualise my data.我对 python 很陌生,我对 matplotlib 很熟悉,到目前为止我知道如何 plot 单独比较这些文件中的每一个,但当然,我希望它们更好地可视化我的下一个数据. here are two of my plots: using plt.boxplot(af,meanline=True,showmeans=True)这是我的两个情节:使用plt.boxplot(af,meanline=True,showmeans=True)

boxplot1 boxplot2线图1 箱线图2

this is how I named/saved my files (just 2 of them here)这就是我命名/保存文件的方式(这里只有 2 个)

af=numpy.loadtxt(fname='af_river.csv.')
am=numpy.loadtxt(fname='am_river.csv.')

but I don't know where to go from here, do I/is there a way to create a loop which goes through each of these files separately and plots them next to each other?但我不知道 go 从这里到哪里,我/是否有办法创建一个循环,分别遍历每个文件并将它们彼此相邻绘制?

Try this尝试这个

plt.boxplot([af,am],meanline=True,showmeans=True)  

This will plot all the files in the same plot这将 plot 中的所有文件 plot

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM