so I've been trying to plot a histogram using python with mathplotlib. So I've got two datasets, basically the heights of a sample of men and women as a list in python, imported off a csv file.
The code that I'm using:
import csv
import numpy as np
from matplotlib import pyplot as plt
men=[]
women=[]
with open('women.csv','r') as f:
r1=csv.reader(f, delimiter=',')
for row in r1:
women+=[row[0]]
with open('men.csv','r') as f:
r2=csv.reader(f, delimiter=',')
for row in r2:
men+=[row[0]]
fig = plt.figure()
ax = fig.add_subplot(111)
numBins = 20
ax.hist(men,numBins,color='blue',alpha=0.8)
ax.hist(women,numBins,color='red',alpha=0.8)
plt.show()
and the error that I get:
Traceback (most recent call last):
File "//MEME/Users/Meme/Miniconda3/Lib/idlelib/test.py", line 22, in <module>
ax.hist(men,numBins,color='blue',alpha=0.8)
File "\\MEME\Users\Meme\Miniconda3\lib\site-packages\matplotlib\__init__.py", line 1811, in inner
return func(ax, *args, **kwargs)
File "\\MEME\Users\Meme\Miniconda3\lib\site-packages\matplotlib\axes\_axes.py", line 5983, in hist
raise ValueError("color kwarg must have one color per dataset")
ValueError: color kwarg must have one color per dataset