3.6 Scatter Chart

1. Scatter Plot

In the Line Chart Plot session, we discussed how to use plt.plot() to draw the line chart. It also can be used to produce a scatter chart. Since it is a scatter plot, we can use plt.scatter() as well.

Figure 1.5.1 Simple Scatter Chart
x = np.linspace(0, 10, 50)
y = np.sin(x)

fig,(ax1,ax2) =plt.subplots(1, 2, figsize = (12,6))

ax1.plot(x, y, 'o', color='firebrick')  # plt.plot()
ax1.set_title('plt.plot way')

ax2.scatter(x, y, marker='o', color='m'); # plt.scatter()
ax2.set_title('plt.scatter way')

2. Markers

We can use Markers to customize a scatter plot, make it more stylish.

For example, we use "star" to draw the same curve.

plt.scatter(x, y, marker='*',color='firebrick');
Figure 1.5.3 Star Scatter Plot

More Marker Types

Figure 1.5.4 More Marker Types

Last updated

Was this helpful?