1.pyecharts作图如下代码图形顺序问题折线图被柱子挡着怎么修改、
2.标记线怎么修改自定义让三条线分别以不同的名字显示、
3.标记线怎么分别改为a类的标记线(b类的标记线。图中的都是a类的标记线如何改成各各类分别对应什么)
4.交叉线tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),后,标记线的标签不显示了能调出来吗
下为此代码的展示效果
标记线的标签不显示了
import numpy as np
import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Map, Timeline, Bar, Line, Pie,Grid
kk1=25
kk2=[85.04,
85.56,
91.4,
95.68,
87.14,
83.14,
72.55,
85.78,
93.85,
80.5,
85.31,
78.47,
79.34,
83.24,
90.71,
76.79,
80.4,
94.21,
87.66,
79.23,
84.16,
86.84,
54.55,
85.68,
80.93]
kk3=[82.28,
83.67,
86.74,
89.93,
83.57,
81.18,
70.59,
83.82,
90.64,
76.81,
83.62,
73.92,
77.31,
79.8,
88.57,
74.4,
78.96,
90.53,
85.26,
77.29,
80.24,
82.73,
52.73,
83.24,
77.54]
kk4=['A1区',
'asd',
'sdfa',
'sdfas',
'dfg',
'qweq',
'B区1',
'B区2',
'B区3',
'sdfasdf',
'asdf',
'sdfa',
'sdfsa',
'dafsdfv',
'dfgds',
'sdfsdf',
'sadfs',
'sdfas',
'sdfa',
'asdfaf',
'sdaf',
'adfa',
'sdafa',
'asdfa',
'sadfsfa']
# B率
zBNUM=80
zBNUM1=70
line1 = (
Line()
.add_xaxis(kk4)
.add_yaxis('B80%指标线',[80 for i in range(kk1)])
.set_series_opts(
label_opts=opts.LabelOpts(is_show=False) , #图形上的数字数据是否显示
))
line2=(
Line() .add_xaxis(kk4)
.add_yaxis('A率70%指标线',[70 for i in range(kk1)])
.set_series_opts(
label_opts=opts.LabelOpts(is_show=False) , #图形上的数字数据是否显示
))
c4 = (
Bar()
.add_xaxis(kk4)
.add_yaxis(
'B率(%)',kk2,
# itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)), #ItemStyleOpts:图元样式配置项
)
.add_yaxis(
'A率(%)',kk3,
# itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)),
)
# 设置Bar左侧y轴 **************************
.extend_axis(
yaxis=opts.AxisOpts(
type_="value",
name="B率(%)",
min_=0,
max_=100,
position="left",
axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(color="#d14a61")
),
axislabel_opts=opts.LabelOpts(formatter="{value}"),
splitline_opts=opts.SplitLineOpts(
is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)
),
)
)
# ******************************************************
.set_global_opts(title_opts=opts.TitleOpts(title="B/A率指标情况"),
# # 设置Bar右侧y轴 设置另外一个y轴**********************
yaxis_opts=opts.AxisOpts(
name="A率(%)",
min_=0,
max_=100,
position="right",
offset=0,
axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(color="#5793f3")
),
axislabel_opts=opts.LabelOpts(formatter="{value}"),
),
# *******************************************************************
tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),
#TooltipOpts:提示框配置项
# 'axis': 坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用。
# 'cross':十字准星指示器。其实是种简写,表示启用两个正交的轴的 axisPointer。
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=18)),
toolbox_opts=opts.ToolboxOpts(orient='horizontal',pos_left='20%',pos_top='25',
#feature参数参考了工具箱工具配置项,工具箱工具配置项中参考了工具箱中最常用的保存图片、还原、数据视图、数据区域缩放、动态类型切换、选框六大配置项
feature=opts.ToolBoxFeatureOpts(save_as_image=opts.ToolBoxFeatureSaveAsImageOpts(),
restore=opts.ToolBoxFeatureRestoreOpts(),
data_view=opts.ToolBoxFeatureDataViewOpts(),
data_zoom=opts.ToolBoxFeatureDataZoomOpts(),
magic_type=opts.ToolBoxFeatureMagicTypeOpts(),
brush=opts.ToolBoxFeatureBrushOpts())),
datazoom_opts=opts.DataZoomOpts(orient="vertical",type_='slider',
range_start=min(float(min(kk3)),zBNUM)-5,
range_end=100)
)
.set_series_opts(
label_opts=opts.LabelOpts(is_show=False),
markline_opts=opts.MarkLineOpts(
data=[opts.MarkLineItem(y=60),
# opts.MarkLineItem(x=5, name="垂直参考下")
opts.MarkLineItem(name="指标要求线AAAAAAAAA",y = 68,# 终点标记的图形。
# ECharts 提供的标记类型包括 'circle', 'rect', 'roundRect', 'triangle',
# 'diamond', 'pin', 'arrow', 'none'
# 可以通过 'image://url' 设置为图片,其中 URL 为图片的链接,或者 dataURI。
symbol =['triangle','triangle'], #一般默认就好
symbol_size = None #标记大小
),
# opts.MarkLineItem(name="中位数线",type_='median'),
opts.MarkLineItem(name="数据线ZZZZZZZZZ",y =50)
],
label_opts= opts.LabelOpts(formatter="60%达标线",is_show=True,color='black'),
linestyle_opts=opts.LineStyleOpts(color='#1cc5dc', type_='dotted')
)
))
# .render("bar_custom_bar_color.html")
# c.render_notebook()
# line1.overlap(line2)
# line1.overlap(c4)
c4.overlap(line1)
c4.overlap(line2)
grid = Grid(init_opts=opts.InitOpts(
animation_opts=opts.AnimationOpts(
animation_delay=480, # 动画延时1秒钟
animation_easing='elasticOut' # 弹性减速动画
),
width='1700px',
# height='500px'
)
)
grid.add(c4, opts.GridOpts(pos_left="3%", pos_right="6.5%"), is_control_axis_index=True)
grid.render("AAAAAA.html")
grid.render_notebook()