...

/

Data Visualization Techniques - Scatter, Line, and Histogram

Data Visualization Techniques - Scatter, Line, and Histogram

Visualization Techniques

1. Scatter Plots

Scatter plots are deceptively simple and commonly used, but simple doesn’t mean that they aren’t useful!

In a scatter plot, data points are represented individually with a dot, circle, or some other shape. These plots are great for showing the relationship between two variables as we can directly see the raw distribution of the data.

To create a scatter plot in Matplotlib we can simply use the scatter method. Let’s see how by creating a scatter plot with randomly generated data points of many colors and sizes.

First, let’s generate some random data points, x and y, and set random values for colors and sizes because we want a pretty plot:

A complete “runnable” example is at the end.

Press + to interact
# Generating Random Data
x = np.random.randn(100)
y = np.random.randn(100)
colors = np.random.rand(100)
sizes = 1000 * np.random.rand(100)

Now that we have our two variables (x, y) and the colors and sizes of the points, we can call the scatter method like this:

plt.scatter(x,
...