Adjust marker sizes and colors in Scatter Plot
Adjust marker sizes and colors in Scatter Plot:
You can specify the marker size with the parameter s and the marker color with c in the plt.scatter()
function.
import matplotlib.pyplot as plt import matplotlib.colors # Prepare a list of integers val = [2, 3, 6, 9, 14] # Prepare a list of sizes that increases with values in val sizevalues = [i**2*50+50 for i in val] # Prepare a list of colors plotcolor = ['red','orange','yellow','green','blue'] # Draw a scatter plot of val points with sizes in sizevalues and # colors in plotcolor plt.scatter(val, val, s=sizevalues, c=plotcolor) # Set axis limits to show the markers completely plt.xlim(0, 20) plt.ylim(0, 20) plt.show()
The following is the output that will be obtained:
2018-11-05T12:16:45+05:30
2018-11-05T12:16:45+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution