python制作雷达图_python实现二维图制作

python全代码如下

import re

import csv

import matplotlib.pyplot as plt

x=[]

y=[]

m=eval(input())        #输入折线条数

for i in range(m):

    y.append([])

fo = open("E:\\shu\\2.txt", "r", encoding='UTF-8')     

plt.ylim(0, 20)                      # 设定y轴范围

for line in fo.readlines():  # 按行输入

    line=line.split("\n")[0]    #分割

    if line !="":    判定是否为空

      don=line.split(" ")

      x.append(don[0])

      for i in range(len(don)-1):     

           y[i].append(eval(don[i+1]))

figsize = 12,8

plt.subplots(figsize=figsize)                                # 设定整张图片大小

plt.grid(True)       # 是否网格化

markes = ['-o', '-s', '-^', '-p', '-^', '-v', '-p', '-d', '-h', '-2', '-8', '-6']

plt.ylabel('Trade account unit: billion US dollars')   #坐标命名

plt.xlabel('time')   #坐标命名

for i in range(m):

    plt.plot(x, y[i],markes[i%12])

plt.legend(['America','china'],loc='upper left')

plt.savefig("Trade account.jpg", dpi=600)    #保存图片

plt.show()

图片效果如下7e2aebb075588dfe5317c1eed15532d2.png文件内容如下

2019-10 -47.2 39.65

2019-11 -43.1 38.73

2019-12 -48.9 46.79

2020-01 -45.3 47.29

2020-02 -39.9 19.93

2020-03 -44.4 45.34

2020-04 -49.4 62.93

2020-05 -54.6 46.42

2020-06 -50.7 62.33

2020-07 -63.6 58.93

2020-08 -67.1 37.00

2020-09 -63.9 58.44

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值