3

I have a following code for pygal graph generation:

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
        )

But with my pretty long legend entries I get the following:

enter image description here

When I comment out truncate I get this:

enter image description here

How can I adjust the number (or width) of columns?

Patryk
  • 22,602
  • 44
  • 128
  • 244

2 Answers2

3

Just so others can more easily find the answer: after a request by the OP, there is now a legend_at_bottom_columns option that can be used as follows:

pie.legend_at_bottom = True
pie.legend_at_bottom_columns = 4
P_S
  • 325
  • 1
  • 3
  • 16
1

Try adding this into your line_chart = pygal.Line():

human_readable = True

With truncate enabled or disabled. See which one works best for you.

Ida Lim
  • 95
  • 3
  • 11
  • @Patryk Hmmm try going to this website: http://cabaret.pygal.org/ This website is an interactive pygal module on browser. Just key in your dataset and format the graph as you desire, after that, try playing around with the options such that your legends can be readable. Then code your pygal according to the options enabled in the interactive pygal browser. – Ida Lim Nov 14 '14 at 08:25