Documentation
Basic customizations
How to customize:
pygal is customized with the help of the Config class (see config.py). It can be changed in several ways:
Size
width, height, explicit_size
The simplest and usefull customizations is the svg size to render. It indicates the desired size of the svg.
You can also set explicit_size to True to add size attributes to the svg tag.
Spacing
spacing, margin
Spacing determines the space between all elements:
Margin is the external chart margin:
Scaling
include_x_axis
Scales are computed automaticaly between the min and the max values.
You may want to always have the absissa in your graph:
range
You may also want to explicitly set a range, range takes a tuple containing min and max:
order_min
Finaly you can tell at which precision pygal should stop scaling (in log10):
Titles
Chart title
title
You can add a title to the chart by setting the title option:
X title
x_title
You can add a title to the x axis by setting the x_title option:
Y title
y_title
You can add a title to the y axis by setting the y_title option:
Font size
title_font_size
Labels
Add labels
x_labels, y_labels
You can specify x labels and y labels, depending on the graph type:
Remove y labels
show_y_labels
Set this to False to deactivate y labels:
Rotate labels
x_label_rotation, y_label_rotation
Allow label rotation (in degrees) to avoid axis cluttering:
Change minor/major labels
x_labels_major, x_labels_major_every, x_labels_major_count, show_minor_x_labels, y_labels_major, y_labels_major_every, y_labels_major_count, show_minor_y_labels
You can alter major minor behaviour of axes thanks to Arjen Stolk
Font size
label_font_size, major_label_font_size
Dots
Removing
show_dots
You can remove dots by setting show_dots at False
show_only_major_dots
You can remove minor x-labelled dots by setting show_only_major_dots at True
Size
dots_size
Legends
Removing
show_legend
You can remove legend by setting these at False
Legend at bottom
legend_at_bottom
You can put legend at bottom by setting legend_at_bottom at True:
Legend box size
legend_box_size
Font size
legend_font_size
Tooltip
Rounded corner
tooltip_border_radius
Font size
tooltip_font_size
Precision
value_formatter
You can specifiy how the values are displayed on the tooltip using a lambda function. The code below shows the values to 2 decimal places.
The datey graph shows the tooltip as "x=? y=?", where the x format is the same as the x_label_format, and the y format is specified via the value_formatter.
Two y axes
secondary
You can plot your values to 2 separate axes, thanks to wiktorn
Rendering
fill, stroke, zero
You can disable line stroking:
And enable line filling:
To fill to an other reference than zero:
Font sizes
value_font_size, tooltip_font_size
Set the various font size
Text truncation
truncate_legend, truncate_label
By default long text are automatically truncated at reasonable length which fit in the graph.
You can override that by setting truncation lenght with truncate_legend and truncate_label.
Human readable
human_readable
Display values in human readable form:
1 230 000 -> 1.23M .00 098 7 -> 987ยต
No data text
no_data_text
Text to display instead of the graph when no data is supplied:
Next: Interpolations