How to change number of scales in pygal?
Last Updated :
24 Jan, 2021
Prerequisites:pygal
Pygal is a Python module that is mainly used to build SVG (Scalar Vector Graphics) graphs and charts. Pygal is a graphics and user interface library for Python that provides functionality commonly required in designing and science applications.
In this article, we will see how we can change the number of scales in pygal. A scale on the graph shows the way the numbers or pictures are used in data. The scale selected for a graph axis has a significant impact on how the audience interprets the message and is an important part of optimizing data visualization. Thus, a scale plays a crucial part in plotting graphs.
Approach
- Import required module.
- Create a chart object.
- Pass maximum/minimum number of scale.
- Label the graph.
- Display Graph.
Syntax:
You can specify the maximum/minimum number of scale graduation to generate with auto-scaling if possible.
Example 1:
Python3
import pygal
import numpy
chart = pygal.Line(min_scale = 40 )
chart.add( 'line' , [ 0 , . 02 , . 05 , . 0035 ])
chart.title = 'Line Chart'
chart.render_to_png( 'aa.png' )
|
Output
Example 2:
Python3
import pygal
import numpy
chart = pygal.Line(max_scale = 3 )
chart.add( 'line' , [ 0 , . 02 , . 05 , . 0035 ])
chart.title = 'Line Chart'
chart.render_to_png( 'aa.png' )
|
Output
Share your thoughts in the comments
Please Login to comment...