mirror of https://github.com/Kozea/pygal.git
Python to generate nice looking SVG graph
http://pygal.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.0 KiB
103 lines
2.0 KiB
10 years ago
|
Interpolations
|
||
|
==============
|
||
|
|
||
10 years ago
|
pygal allow you to interpolate most of line charts. Take this chart for instance:
|
||
10 years ago
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line()
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
|
||
10 years ago
|
interpolate
|
||
|
-----------
|
||
|
|
||
|
cubic
|
||
|
~~~~~
|
||
|
|
||
|
You can set the cubic interpolation:
|
||
10 years ago
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='cubic')
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
|
||
10 years ago
|
quadratic
|
||
|
~~~~~~~~~
|
||
10 years ago
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='quadratic')
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
|
||
10 years ago
|
lagrange
|
||
|
~~~~~~~~
|
||
10 years ago
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='lagrange')
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
|
||
10 years ago
|
trigonometric
|
||
|
~~~~~~~~~~~~~
|
||
10 years ago
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='trigonometric')
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
|
||
10 years ago
|
hermite
|
||
|
~~~~~~~
|
||
10 years ago
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='hermite')
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
|
||
10 years ago
|
interpolation_parameters
|
||
|
------------------------
|
||
10 years ago
|
|
||
10 years ago
|
For hermite you can also pass additionnal parameters to configure tangent behaviour:
|
||
10 years ago
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='hermite', interpolation_parameters={'type': 'finite_difference'})
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='hermite', interpolation_parameters={'type': 'cardinal', 'c': .75})
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='hermite', interpolation_parameters={'type': 'kochanek_bartels', 'b': -1, 'c': 1, 't': 1})
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
For more information see the `wikipedia article <http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference>`_
|
||
|
|
||
|
|
||
10 years ago
|
interpolation_precision
|
||
10 years ago
|
-----------------------
|
||
|
|
||
10 years ago
|
You can change the resolution of the interpolation with the help of ``interpolation_precision``:
|
||
10 years ago
|
|
||
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='quadratic')
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|
||
|
.. pygal-code::
|
||
|
|
||
|
chart = pygal.Line(interpolate='quadratic', interpolation_precision=3)
|
||
|
chart.add('line', [1, 5, 17, 12, 5, 10])
|
||
|
|