Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introduction to Data Visualization with Matplotlib Chart Toppers Histogram

iris data

Hello. Where do you get your iris data set from? I can't plot the histogram, nor the scatterplot, so perhaps my data is the issue.

There's no error: just a blank set of axes.

import csv
import matplotlib.pyplot as plt

input_file = "data/iris.csv"
plt.figure(figsize=(7.5, 4.25))

with open(input_file, 'r') as iris_data:
    irises = list(csv.reader(iris_data))

virginica_petal_length = []

num_bins = 10

for petal in range(0, len(irises)-1):
    if irises[petal][4] == 'Iris-virginica':
        virginica_petal_length.append(float(irises[petal][2]))

plt.hist(virginica_petal_length, num_bins, facecolor='red', alpha=0.75)

plt.title('Iris-virginica Petal Length', fontsize=12)
plt.xlabel('Petal Length (cm)', fontsize=10)
plt.ylabel('Probability', fontsize=10)

plt.show()

Your help is much appreciated.

Hi, did you downloaded the ZIP file, the one that is in the download tab; underneath the video?

If not, then if you download and unzip it, you will see that the data set is first located in a folder called s2vi :dizzy:

Other than that, will have to look into it more.

4 Answers

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

carlaos91 is correct.

You can also find the reference repository at UC Irvine Machine Learning repository.

Here is the description,

https://archive.ics.uci.edu/ml/datasets/iris

Here are the files,

https://archive.ics.uci.edu/ml/machine-learning-databases/iris/

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

My reasoning to link the UC Irvine repository is that a motivated learner might become inspired by their repository which has some excellent "clean" data products ripe for experiments in Machine Learning and Data Science.

Good luck on your Data Science journey!

Thank you so much, Jeff!

I'm hoping my feedback would reach the instructor or staff: see this first video has links to the Wiki page, and there's another link to another link to get to IEEE's page ... not the best user experience, but again, Jeff, I'm really thankful for the links you just sent. My code now works! :)

Thanks Jeff!

Hi carlaos91, I'm sure whatever URL you're going to is correct, but I have not seen this folder called s2vi, even though I've heard of it from you in other responses. If you can post a URL to this place, that would be gladly appreciated!