If you are reading the book, you can get the notebooks by cloning this repository on GitHub and running the notebooks on your computer. Or you can read (but not run) the notebooks on GitHub:
I’ll post the next batch soon; in the meantime, here are some of the examples from Chapter 7, demonstrating the surprising difficulty of making an effective scatter plot, especially with large datasets (in this example, I use data from the Behavioral Risk Factor Surveillance System, which includes data from more than 300,000 respondents).
I’ll start with the data from the BRFSS again.
df = brfss.ReadBrfss(nrows=None)
def SampleRows(df, nrows, replace=False): indices = np.random.choice(df.index, nrows, replace=replace) sample = df.loc[indices] return sample
sample = SampleRows(df, 5000) heights, weights = sample.htm3, sample.wtkg2
alpha=1, so each data point is fully saturated.
thinkplot.Scatter(heights, weights, alpha=1) thinkplot.Config(xlabel='Height (cm)', ylabel='Weight (kg)', axis=[140, 210, 20, 200], legend=False)