Skip to content

Instantly share code, notes, and snippets.

@hackintoshrao
Last active January 28, 2018 17:22
Show Gist options
  • Save hackintoshrao/b68a63c071e74ef1c9e434f8cce593d6 to your computer and use it in GitHub Desktop.
Save hackintoshrao/b68a63c071e74ef1c9e434f8cce593d6 to your computer and use it in GitHub Desktop.
The scatter plot of university admission data.
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
# extract data frame columns into numpy array.
test_scores = data["test_scores"].values
grades = data["grades"].values
label = data["accepted"].values
# There's a total of 100 student records.
print("Total number of records: ", len(test_scores))
# plot the points.
# The green points indicates the students who are accepted.
# The red ones indicate the ones who are rejected.
colors = ['green','red']
fig = plt.figure(figsize=(4,4))
plt.scatter(test_scores, grades, c=label, cmap=matplotlib.colors.ListedColormap(colors))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment