Horje
How to change number of scales in pygal?

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:

  • min_scale 
  • max_scale

You can specify the maximum/minimum number of scale graduation to generate with auto-scaling if possible.

Example 1:

Python3

# importing pygal
import pygal
import numpy
  
  
# creating the chart object
# minimum number of scale
chart = pygal.Line(min_scale=40)
  
# Random data
chart.add('line', [0, .02, .05, .0035])
  
# naming the title
chart.title = 'Line Chart'
  
chart.render_to_png('aa.png')

Output

Example 2:

Python3

# importing pygal
import pygal
import numpy
  
  
# creating the chart object
# maximum number of scale
chart = pygal.Line(max_scale=3)
  
# Random data
chart.add('line', [0, .02, .05, .0035])
  
# naming the title
chart.title = 'Line Chart'
  
chart.render_to_png('aa.png')

Output




Reffered: https://www.geeksforgeeks.org


Python

Related
How to Change the Color of a Graph Plot using pygal? How to Change the Color of a Graph Plot using pygal?
Avoid TLE in Python in Competitive Programming Avoid TLE in Python in Competitive Programming
How to Automate an Excel Sheet in Python? How to Automate an Excel Sheet in Python?
Create a Real Time Currency Converter app using Flask | Python Create a Real Time Currency Converter app using Flask | Python
How to Integrate Custom Rich Text-Editor in Your Django Website? How to Integrate Custom Rich Text-Editor in Your Django Website?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
7