不幸的是,有没有标签pyecharts在stackoverflow网站,我不知道如果我会得到一个有帮助的答案,希望我会得到
我有下面的图表,其中包括两个酒吧和一条线,我需要2件事:
1.我需要将行移到条的前面,默认情况下它位于条的下面
1.我需要将数值缩短到最近的千位数(例如80,000 = 80 K)
代码:-
from pyecharts.charts import Bar, Gauge, Line
from pyecharts import options as opts
from pyecharts.globals import ThemeType
bar = (
Bar(init_opts=opts.InitOpts(width='100%', theme=ThemeType.VINTAGE))
.add_xaxis(["Category-1" , "Category-2", "Category-3", "Category-4", "Category-5"])
.add_yaxis('No. Of Investments', [100,700,900,500,400,50], label_opts=opts.LabelOpts(is_show=False),)
.add_yaxis('No. Of Investors', [24,65,30,41,88], label_opts=opts.LabelOpts(is_show=False),)
.extend_axis(
yaxis=opts.AxisOpts(
name="Value",
type_="value",
name_textstyle_opts=opts.TextStyleOpts(font_size=14, font_weight='bold', font_family='Dubai')
)
)
.set_global_opts(legend_opts=opts.LegendOpts(is_show=True ,
pos_right = 0,
textstyle_opts = opts.TextStyleOpts(font_size=14, font_weight='bold', font_family='Dubai') ),
yaxis_opts=opts.AxisOpts(
name='Count',
name_location='middle',
name_gap=50,
type_="value",
axistick_opts=opts.AxisTickOpts(is_show=True),
splitline_opts=opts.SplitLineOpts(is_show=True),
axispointer_opts=opts.AxisPointerOpts(is_show=False),
name_textstyle_opts=opts.TextStyleOpts(
font_size=14, font_weight='bold', font_family='Dubai')
),
xaxis_opts=opts.AxisOpts( type_="category",
axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"),
name_textstyle_opts=opts.TextStyleOpts(font_size=14, font_weight='bold', font_family='Dubai') ,
axislabel_opts = opts.LabelOpts(font_family='Dubai' ,
rotate = 30,
font_size= 11,
)
),
tooltip_opts=opts.TooltipOpts(
is_show=True,
trigger="axis",
textstyle_opts = opts.TextStyleOpts( font_family='Dubai')
) ,
toolbox_opts = opts.ToolboxOpts(is_show=True , pos_left= '5%',
feature=opts.ToolBoxFeatureOpts(
data_zoom = opts.ToolBoxFeatureDataZoomOpts(is_show=False) ,
data_view = opts.ToolBoxFeatureDataViewOpts(is_show=False) ,
brush=None
) )
)
)
line = (
Line()
.add_xaxis(["Category-1" , "Category-2", "Category-3", "Category-4", "Category-5"])
.add_yaxis('Investments Valaue', [50500,60020,84000,30150,41200],
yaxis_index=1,
label_opts=opts.LabelOpts(is_show=False),
linestyle_opts = opts.LineStyleOpts(width=2)
)
)
bar.overlap(line).render_notebook()
感谢你的帮助
1条答案
按热度按时间zu0ti5jz1#
提供的文档和示例中似乎缺少避免pyecharts中条形图和折线图重叠的选项。尝试合并条形图和折线图时,条形图始终显示在折线图前面,而不管图表添加到绘图中的顺序如何。作为一种解决方法,您可以向条形图添加透明度,以使折线图在条形图上部分可见。