[Python Study Notes] colorful scatter plot

Source: Internet
Author: User

"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "". "" "" "" "" "" "" "" "," "" "" "," "" "" "," "" "," "" ">> 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.