# -*- coding: UTF-8 -*-
__author__ = 'zy'
__time__ = '2020/4/20 13:38'
import json
import time
import pandas as pd
import matplotlib
matplotlib.rcParams['backend'] = 'SVG'
import matplotlib.pyplot as plt
import pandas
import requests
import numpy as np
plt.rcParams['font.family'] = ['sans-serif']
plt.rcParams['font.sans-serif'] = ['SimHei']
 
df = pandas.read_csv('day_sen0.csv', engine='python', sep=',', encoding="utf_8_sig")
neg=df['neg'].values.tolist()
neu=df['neu'].values.tolist()
pos=df['pos'].values.tolist()
rate=df['rate'].values.tolist()
 
time_l=df['time'].values.tolist()
 
plt.plot(time_l, rate,'m.-.')  # plot在一个figure窗口中添加一个图,绘制曲线,默认颜色
# 绘制离散点
plt.plot(time_l, rate, '.y')  # 绘制黄色的点,为了和曲线颜色不一样
 
plt.plot(time_l, rate, 'om')  # 绘制紫红色的圆形的点
 
plt.plot(['2020/1/23', '2020/1/23'], [0.11, rate[time_l.index('2020/1/23')]], "--", color="g")
 
for x0, y0 in zip(time_l, rate):
    if x0=='2020/1/23':
        plt.annotate('label1', xy=(x0, y0), xytext=(x0, y0 +0.01), )  # 添加注释arrowprops=dict(arrowstyle='->')
        # plt.quiver(x0, y0 - 0.04, 0, 1, color='g', width=0.005)  # 绘制箭头
        plt.plot(x0, y0, 'or')
    if x0=='2020/2/10':
        plt.annotate('label2', xy=(x0, y0), xytext=(x0, y0 + 0.01))  # 添加注释
        plt.quiver(x0, y0 - 0.04, 0, 1, color='g', width=0.005)  # 绘制箭头
        plt.plot(x0, y0, 'or')
# x = range(2, 21, 5)
# y = np.log10(x) + 0.5
# xytext=(x0, y0 - 1),
 
# plt.annotate('Original point', xy=(2020/1/23, rate[time_l.index(2020/1/23)]),arrowprops=dict(arrowstyle='->'))
 
 
 
plt.xticks(list(time_l)[::6],time_l[::6],)
 
import pylab as pl
 
pl.xticks(rotation=45)
 
# plt.xlabel('date')
plt.ylabel('rate')
 
plt.legend()
 
print(df)
plt.savefig('1.png')
# plt.show()
 
plt.savefig('kankan.svg',format='svg')

python 绘制svg之后利用 Adobe illustrator进行渲染