Python中的数据可视化

import numpy as np

import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif']='SimHei'

plt.rcParams['axes.unicode_minus']=False

def function1():

    courses = np.array(['语文', '数学', '英语', '物理', '化学', '生物'])

    scores = np.array([[95, 75, 86],

                       [96, 93, 76],

                       [63, 85, 93],

                       [91, 88, 67],

                       [86, 76, 87]])

    data_length = len(scores)

    angles = np.linspace(0, 2 * np.pi, data_length, endpoint=False)

    scores = np.concatenate((scores, [scores[0]]))

    angles = np.concatenate((angles, [angles[0]]))

    plt.polar(angles, scores, 'o-', linewidth=3)

    plt.thetagrids(angles * 180 / np.pi, courses, fontproperties='simhei')

    plt.legend(['高二1班', '高二2班', '高二3班'], loc=(0.94, 0.80), labelspacing=0.1)

    plt.show()

def function2():

    courses = np.array(['语文', '数学', '英语', '物理', '化学', '生物'])

    scores1 = np.array([95, 96, 85, 63, 91, 86])

    scores2 = np.array([75, 93, 66, 85, 88, 76])

    scores3 = np.array([86, 76, 96, 93, 67, 87])

    # k=np.linspace(1,6,6)

    # plt.thetagrids(k,courses,fontproperties='simhei')

    x = [1, 2, 3, 4, 5, 6]

    plt.xticks(x, courses)

    plt.plot(x, scores1)

    plt.plot(x, scores2)

    plt.plot(x, scores3)

    plt.legend(['高二1班', '高二2班', '高二3班'], loc=(0.94, 0.80), labelspacing=0.1)

    plt.title("成绩评估")

    plt.show()

def function3():

    courses = np.array(['语文', '数学', '英语', '物理', '化学', '生物'])

    scores1 = np.array([95, 96, 85, 63, 91, 86])

    scores2 = np.array([75, 93, 66, 85, 88, 76])

    scores3 = np.array([86, 76, 96, 93, 67, 87])

    # k=np.linspace(1,6,6)

    # plt.thetagrids(k,courses,fontproperties='simhei')

    x = [1, 2, 3, 4, 5, 6]

    plt.xticks(x, courses)

    plt.scatter(x, scores1)

    plt.scatter(x, scores2)

    plt.scatter(x, scores3)

    plt.legend(['高二1班', '高二2班', '高二3班'], loc=(0.94, 0.80), labelspacing=0.1)

    plt.title("成绩评估")

    plt.show()

def function4():

    courses = np.array(['语文', '数学', '英语', '物理', '化学', '生物'])

    scores1 = np.array([95, 96, 85, 63, 91, 86])

    scores2 = np.array([75, 93, 66, 85, 88, 76])

    scores3 = np.array([86, 76, 96, 93, 67, 87])

    x = np.linspace(0, 6, 6)

    plt.xticks(x, courses)

    width = 0.15

    plt.bar(x - width, scores1, width=0.15)

    plt.bar(x, scores2, width=0.15)

    plt.bar(x + width, scores3, width=0.15)

    plt.legend(['高二1班', '高二2班', '高二3班'], loc=(0.94, 0.80), labelspacing=0.1)

    plt.title("成绩评估")

    plt.show()

function1()

function2()

function3()

function4()

9f9c323af856465e8682aae217cc13e9.png

e59c8fce3b5d4e329321dd54a6751e0f.png 

5988b7613ccb4763a0b1531e19608ca8.png 

 

  • 24
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值