python - 如何使 pygal 将图例分布到 n 列或正确截断?

标签 python legend pygal

我有以下用于 pygal 图形生成的代码:

import pygal
from pygal.style import Style
style = Style(
        background='white',
        plot_background='rgba(0, 0, 255, 0.03)',
        foreground='rgba(0, 0, 0, 0.8)',
        foreground_light='rgba(0, 0, 0, 0.9)',
        foreground_dark='rgba(0, 0, 0, 0.7)',
        colors=('#5DA5DA', '#FAA43A','#60BD68', '#F17CB0', '#4D4D4D', '#B2912F','#B276B2', '#DECF3F', '#F15854')
        )
line_chart = pygal.Line(
        include_x_axis=True,
        width=1080,
        #height=1600,
        print_values=False,
        style=style,
        label_font_size=18,
        margin=10,
        title_font_size=26,
        x_title='seconds',
        y_title='frames per second',
        # Legend
        legend_box_size=12,
        legend_font_size=16,
        truncate_legend=50,
        legend_at_bottom=True
        )

但是根据我相当长的图例条目,我得到以下内容:

enter image description here

当我注释掉 truncate 时,我得到了这个:

enter image description here

如何调整列数(或宽度)?

最佳答案

只是为了让其他人更容易找到答案:在a request by the OP之后, 现在有 a legend_at_bottom_columns option可以按如下方式使用:

pie.legend_at_bottom = True
pie.legend_at_bottom_columns = 4

关于python - 如何使 pygal 将图例分布到 n 列或正确截断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25938015/

相关文章:

r - 使用 gghighlight 时为多个 geom_hlines 创建图例

r - 在 ggplot 中向 barplot 添加图例

Python Pygal : Setting serie color

r - 禁用图例双击事件

python - pygal:多系列饼图上的标签

django - 我如何在 Django 模板中嵌入 pygal 图表

python - Django 同步数据库 : access denied

python - 尝试使用 Boto3 从 S3 下载特定类型的文件 - TypeError : expected string or bytes-like object

python - 如何获取MySQL分组内的计数

python - 添加到字典列表 - python