concept scatterplot in category dask

This is an excerpt from Manning's book Data Science with Python and Dask.
Notice that Anscombe’s quartet is a very small dataset, so visualizing it as a set of scatterplots is simple and straightforward. However, visualizing large datasets can be tricky due to both the volume and variety of data. Because there are many kinds of visualizations to choose from, for all different kinds of data, we can’t possibly cover all kinds of visualizations in this book. Therefore, we will cover some general patterns and tactics that you can extend to produce many kinds of visualizations, and we will cover a few of the more common visualizations that are useful for analyzing structured data. As always, figure 7.2 shows what we’ve accomplished so far and where we’ll turn our focus next.
The other thing we have to keep in mind when plotting large datasets is that the value of visualization comes from the ability to quickly and intuitively discern insights from the data. However, it can be quite easy to become overwhelmed when faced with a large amount of data. Take a look at the scatterplot in figure 7.3.
Figure 7.3 An example of a very dense scatterplot
![]()
It’s really hard to tell what’s going on at all in the scatterplot because so many individual points have been plotted on it. It simply looks like random noise! Applying some color coding could make it possible to see a few distinct regions in the data, but it would still be difficult to see where those regions begin and end and where they overlap with one another. This is a hallmark issue with visualizing large datasets: with so much data, individual data points stop being useful to analyze individually. Rather, we need to distill broad patterns and behaviors out of the data. We could do this in a number of ways, including clustering, aggregating, or sampling. Any of these three techniques can be used to make the data much easier to understand.
7.2.2 Adding a linear regression line to the scatterplot
We can have Seaborn try to help us see the gradual pattern in the data better by plotting a regression plot instead of a scatterplot. To do that, we’ll use the
regplotfunction. Its required parameters are the same as thescatterplotfunction, so it’s very easy to interchange the two.Listing 7.4 Adding a regression line to a scatterplot using
regplotseaborn.set(style="whitegrid") f, ax = plt.subplots(figsize=(10, 10)) seaborn.despine(f, left=True, bottom=True) with ProgressBar(): seaborn.regplot(x="Temp", y="Summons Number", data=citationsAndTemps.compute(), ax=ax, robust=True) plt.ylim(ymin=0) plt.xlim(xmin=0)In listing 7.4., you can see that the only thing that changed is the call to
regplotinstead ofscatterplot. We also added the optional parameter,robust. This parameter tells Seaborn to produce a robust regression. A robust regression minimizes the influence of outliers on the regression equation. This means that points on the y axis that sit far away from other points won’t pull the line we’re trying to draw through the points up (or down) by very much. This is a good thing since these points are unlikely to occur on a regular basis, so we should treat them as anomalies instead of observations that are likely to happen again. For example, take a look at the point in figure 7.6 that represents roughly 1.4 million citations. This happened during a very cold month when the average temperature was only about 30 degrees Fahrenheit. We can see that all the other months that were just as cold accrued only around 700,000 citations. Some special circumstance must have happened during the month where 1.4 million citations were issued, since this seems to be unusual. If we allowed the anomalous data point to influence our regression line, it would cause us to overestimate the number of citations we can expect to be issued in cold months. There seem to be a few outliers in this dataset, so using a robust regression would be a good idea. When running the code, you will get a regression plot that looks like figure 7.7.