A plurality of linear distortion Python3 matplotlib.pyplot Chinese add legends

# After Import 
font = {
     ' Family ' : ' SimHei ' 
} 
matplotlib.rc ( ' font ' , font **)
# -*- coding:utf-8 -*-
import numpy as np  
import matplotlib.pyplot as plt
import  matplotlib

font = {
    'family' : 'SimHei'
}
matplotlib.rc('font', **font)

day="6-1,6-2,6-3".split(',')
v="建信50 | 0.8502/0.8499/0.8496    | 0.8263/0.8239/0.8253 | 0.0260/0.0246".split('|')
#print(day)
name=v[0]

#print("name",name)

myValue=[]
for m in v[1].split('/'):
    myValue.append(float(m))
curValue=[]
for m in v[2].split('/'):
    curValue.append(float(m))
#print(myValue)
#print(curValue)
z=[]
#整理差值数据
for i in range(len(day)):
    z.append((myValue[i]-curValue[i])*10)
print("差值",z)    
#print(type(z))

plt.figure()  
#plt.plot(day,z)  
#plt.savefig("easyplot.png")  
#plt.show()

plt.plot(day, myValue, color = 'blue', linewidth = 2.0, linestyle = '-',label="持仓成本价")
plt.plot(day, curValue, color = 'red', linewidth = 2.0, linestyle = '--',label="当前净值")
# Plt.plot (Day, Z, Color = 'Red', as linewidth = 2.0, lineStyle = '-', U label = "difference value") 

plt.legend ()   # shown above label 
plt.title (name) # Add a title 

plt.show ()

 

Guess you like

Origin www.cnblogs.com/ives/p/10974183.html