Pycharsは複数のデータをプロットします
import pandas as pd
from pyecharts.charts import Bar, Pie, Line
from pyecharts import options as opts
from pyecharts.render import make_snapshot
from pyecharts.globals import ThemeType
from snapshot_selenium import snapshot
from sqlalchemy import create_engine
from pyecharts import options as opts
class draw_bar():
def __init__(self):
self.df = pd.read_excel(r"./word.xlsx").set_index('word')
self.Line = Line()
x = (self.df.columns.tolist())
x.reverse()
self.Line.add_xaxis(x)
def get_words(self):
with open("./待查询.txt", 'r', encoding='utf-8') as f:
words = f.readlines()
return words
def draw(self, words):
for word in words:
y = (self.df.loc[word.strip()].astype('int64').tolist())
y.reverse()
self.Line.add_yaxis(word, y)
self.Line.set_global_opts(
title_opts=opts.TitleOpts(title="主标题: Amazon数据热度", subtitle="关键词排名"))
self.Line.set_series_opts(label_opts=opts.LabelOpts(position='right', font_size=5)),
make_snapshot(snapshot, self.Line.render(path=r"./动态/关键词.html"), "./动态/Line.png")
def run(self):
words = self.get_words()
self.draw(words)
if __name__ == '__main__':
d = draw_bar()
d.run()