from matplotlib.pyplot import title
from pyecharts.options.global_options import TitleOpts
from collections import namedtuple
import json
import sys
import zipfile
import os
from collections import defaultdict
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.backends.backend_pdf import PdfPages
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.charts import Pie
from pyecharts.commons.utils import JsCode
from pyecharts.globals import ThemeType
def PlotMultMSBar(start_time, end_time,path):
with open(path + "\\data\\mahcine_status.json","r") as json_file:
Msdata = json.load(json_file)
MsName = [1,1,1,1]
MsOther = [2,2,2,2]
MsProduct = [3,3,3,3]
MsWaitLoad = [4,4,4,4]
MsWaitUnLoad = [5,5,5,5]
c = (
Bar(init_opts=opts.InitOpts(width="1680px", height="800px")) #设置画布大小
.add_xaxis(MsName) #横坐标
.add_yaxis("Other", MsOther, stack="stack1", category_gap="50%")
.add_yaxis("Product", MsProduct, stack="stack1", category_gap="50%")
.add_yaxis("WaitLoad", MsWaitLoad, stack="stack1", category_gap="50%")
.add_yaxis("WaitUnLoad", MsWaitUnLoad, stack="stack1", category_gap="50%")
.set_global_opts(
title_opts=opts.TitleOpts(title=start_time + "-" + end_time),
)
.set_colors(["blue", "green", "purple", "red"]) #设置颜色的
.render(path + "\\data\\" + "MsMultBar.html")
)
python使用pyecharts库画多柱状图
最新推荐文章于 2024-07-25 11:24:24 发布