Q. Given two arrays namely arr1 and arr2, each having 5 values. Create a scatter chart so that each data points gets a different color, different size. Keep the marker style as square.


Answer :-

import matplotlib.pyplot as pl
import numpy as np

arr1 = np.linspace(-1, 1, 5)
arr2 = np.exp(arr1)

colors = ['r', 'b', 'k', 'g', 'm']
sizes = [50, 120, 220, 150, 80]

pl.scatter(arr1, arr2, c = colors, s= sizes, marker = 's')
pl.show()


Output :-

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post