[Python Study Notes]七彩散点图绘制

‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘
>>文件: 七彩散点图.py
>>作者: liu yang
>>邮箱: [email protected]
>>博客: www.cnblogs.com/liu66blog

‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, os
import matplotlib.pyplot as plt
import numpy as np
import random

# 七彩散点图 Colorful scatterplot
def scatterplot_colorful():
    # 输入横坐标x序列
    x=np.array([x for x in range(1,21)])
    # 输入y序列,或者y与x的关系
    y=x**2
    # 定义颜色的列表
    colors=[‘red‘,‘green‘,‘gray‘,‘purple‘,‘yellow‘,‘orange‘,‘blue‘]
    # 随机排列颜色
    random_colors=random.sample(colors,7)
    # print(random_colors)
    # 生成一个画布
    fig=plt.figure()
    # 散点图绘制
    plt.scatter(x,y,s=100,c=random_colors,alpha=0.8)
    plt.xticks(x)
    # 显示获得图片
    fig.show()
    # 或者
    # plt.show()

# 如果当前模块作为主模块运行
if __name__ == ‘__main__‘:
    # 实例化七彩散点图
    sca=scatterplot_colorful()

原文地址:https://www.cnblogs.com/liu66blog/p/8486078.html

时间: 2024-10-09 08:00:27

[Python Study Notes]七彩散点图绘制的相关文章

[Python Study Notes]气泡散点图绘制

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 气泡散点图.py >>作者: liu yang >>邮箱: [email protected] >>博客: www.cnblogs.com/liu66blog '''''''''''''''''''''''''''''''''''''''''''''

[Python Study Notes]堆叠直方图绘制

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 堆叠直方图.py >>作者: liu yang >>邮箱: [email protected] >>博客: www.cnblogs.com/liu66blog '''''''''''''''''''''''''''''''''''''''''''''

[Python Study Notes]双层直方图绘制

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 双层直方图.py >>作者: liu yang >>邮箱: [email protected] >>博客: www.cnblogs.com/liu66blog '''''''''''''''''''''''''''''''''''''''''''''

[Python Study Notes]折线图绘制

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 折线图.py >>作者: liu yang >>邮箱: [email protected] >>博客: www.cnblogs.com/liu66blog '''''''''''''''''''''''''''''''''''''''''''''''

[Python Study Notes]饼状图绘制

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 饼状图.py >>作者: liu yang >>邮箱: [email protected] >>博客: www.cnblogs.com/liu66blog '''''''''''''''''''''''''''''''''''''''''''''''

[Python Study Notes]正则表达式

正则表达式 正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配. Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达式模式. re 模块使 Python 语言拥有全部的正则表达式功能. compile 函数根据一个模式字符串和可选的标志参数生成一个正则表达式对象.该对象拥有一系列方法用于正则表达式匹配和替换. re 模块也提供了与这些方法功能完全一致的函数,这些函数使用一个模式字符串做为它们的第一个参数. 本章节主要介绍Python中常用

[Python Study Notes]计算cpu使用率

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: cpu使用率.py >>作者: liu yang >>邮箱: [email protected] ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

[Python Study Notes]计算cpu使用率v0.1

V0.1 更新日志: 1.加入平台判断,支持windows与linux 2.自动清屏显示,显示更加直观 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: cpu使用率.py >>作者: liu yang >>邮箱: [email protected] ''''''''''''''''''''''''''''''

[Python Study Notes]磁盘分区和io性能

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 磁盘信息.py >>作者: liu yang >>邮箱: [email protected] ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''