How to Plot Scatter in Numpy Python?


The Scatter Plot is often used to show vivid relations between two variables. Plotting is made very simple and easy in Python using numpy and matplotlib.pylab package.

To demonstrate, we create two random vectors of same size, x and y.

import numpy as np
x=np.random.rand(100)
y=np.random.rand(100)

Then we can plot it:

import matplotlib.pylab as plt
plt.scatter(x, y, s=20, c='g', marker='o')

The first two parameters are mandatory while the rest are optional. The parameter s specifies the marker size and the c gives the color of the marker while the last parameter gives the marker style.

python-numpy-scatter-plot How to Plot Scatter in Numpy Python? geometry graph graphs programming languages python

Plot scatter in Python Numpy

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
206 words
Last Post: How to Extract Multiple Columns from NumPy 2D Matrix?
Next Post: How to Delete Trash File from Your Windows System using Batch Script?

The Permanent URL is: How to Plot Scatter in Numpy Python?

2 Comments

  1. YT

Leave a Reply