简体   繁体   中英

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.

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. here are two of my plots: using plt.boxplot(af,meanline=True,showmeans=True)

boxplot1 boxplot2

this is how I named/saved my files (just 2 of them here)

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?

Try this

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

This will plot all the files in the same plot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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