"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "". "" "" "" "" "" "" "" "," "" "" "," "" "" "," "" "," "" ">> Colorful Scatter chart .py>> Author: Liu Yang>> e-mail: [email protected]>> blog: Www.cnblogs.com/liu66blog "" ". "" "" "" "" "" "" "" "" "" "" "" "" "" "" "." "" "" "" "" "" "" "" "" "" "" "" "" #!/usr/bin/env python#-*-. " Coding:utf-8-*-import sys, osimport matplotlib.pyplot as Pltimport numpy as Npimport random# colorful scatter plot colorful scatterplotd EF scatterplot_colorful (): # input horizontal x sequence X=np.array ([x for X in range (1,21)]) # Enter Y sequence, or y relationship to X y=x**2 # defines the column of the color Table colors=[' red ', ' green ', ' gray ', ' purple ', ' yellow ', ' orange ', ' Blue ' # randomly arranged colors random_colors=random.sample (colors,7) # print (random_colors) # generates a canvas fig=plt.figure () # Scatter plot plot plt.scatter (x,y,s=100,c=random_colors,alpha=0.8) Plt.xticks (x) # Show get Picture fig.show () # or # plt.show () # If the current module runs as the main module if __name__ = = ' __main__ ': # Instantiate a colorful scatter plot Sca=scatterplot_colorful ()
[Python Study Notes] colorful scatter plot