pyecharts-gallery icon indicating copy to clipboard operation
pyecharts-gallery copied to clipboard

使用grid组合两张饼图时无法改变饼图位置导致重合

Open LZhangGJ opened this issue 3 years ago • 1 comments

代码如下:

from pyecharts import options as opts from pyecharts.charts import Pie from pyecharts.faker import Faker

c1 = ( Pie() .add( "", [list(z) for z in zip(Faker.choose(), Faker.values())], radius=["40%", "75%"], ) .set_global_opts( title_opts=opts.TitleOpts(title="Pie-Radius"), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%"), ) .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}")) ) from pyecharts import options as opts from pyecharts.charts import Pie from pyecharts.faker import Faker

c2 = ( Pie() .add( "", [list(z) for z in zip(Faker.choose(), Faker.values())], radius=["40%", "75%"], ) .set_global_opts( title_opts=opts.TitleOpts(title="Pie-Radius"), legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%"), ) .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}")) )

grid = (
Grid()
.add(c1, grid_opts=opts.GridOpts(pos_top=10))
.add(c2, grid_opts=opts.GridOpts(pos_top = 100))
)

grid.render_notebook()

结果两张饼图完全重合,代码均来自gallery。 我在使用自己的数据集时也出现了相同的问题 希望能解答,万分感谢

LZhangGJ avatar Mar 24 '22 09:03 LZhangGJ

另外使用饼图与其它任意图表结合似乎都存在相同问题

LZhangGJ avatar Mar 24 '22 09:03 LZhangGJ

如果在这个图中能设置位置,你需要在图中设置位置,而不是在grid中进行设置。你需要在饼图中设置center这个参数。

x18-1 avatar May 03 '24 08:05 x18-1

@LZhangGJ

x18-1 avatar May 03 '24 08:05 x18-1