Create charts and publish on Amazon S3.
Project description
This module contains methods for producing graphs and publishing them on Amazon S3, or in the location of your choice.
It is written and maintained for `Newsworthy <https://www.newsworthy.se/en/>`_, but could possibly come in handy for other people as well.
By `Journalism++ Stockholm <http://jplusplus.org/sv>`_.
Installing
----------
.. code:: bash
pip install newsworthy-charts
Using
-----
This module comes with two classes, `Chart` and `Storage` (and it's subclasses).
When using the Chart class, the generated chart will be saved as a local file:
.. code:: python3
from newsworthycharts import SerialChart
c = Chart(600, 800)
c.title = "Number of smiles per second"
c.xlabel = "Time"
c.ylabel = "Smiles"
c.caption = "Source: Ministry of smiles."
data_serie_1 = [("2008-01-01", 6.1), ("2009-01-01", 5.9), ("2010-01-01", 6.8)]
c.data.append(data_serie_1)
c.highlight = "2010-01-01"
c.render("test", "png")
You can use a _storage_ object to save file to
a specific location or cloud service:
.. code:: python3
from newsworthycharts import Chart
from newsworthycharts import S3Storage
s3 = S3Storage("my_bucket")
c = Chart(600, 800, storage=s3)
c.title = "Number of smiles per second"
c.xlabel = "Time"
c.ylabel = "Smiles"
c.caption = "Source: Ministry of smiles."
c.render("test", "png")
To store a file in a local folder, use the `LocalStorage` class:
.. code:: python3
from newsworthycharts import LocalStorage
storage = LocalStorage("/path/to/generated/charts")
Charts are styled using built-in or user-defined styles:
.. code:: python3
from newsworthycharts import Chart
# This chart has the newsworthy default style
c = Chart(600, 800, style="newsworthy")
# Style can also be the path to a style file (absolute or relative to current working directory)
c2 = Chart(600, 800, style="path/to/styles/mystyle.mplstyle")
To set up you own style, copy the build-in default: <https://github.com/jplusplus/newsworthycharts/blob/master/newsworthycharts/rc/newsworthy>
Newsworthycharts will look first among the predefined style files for the requested style, so if you have a custom style file in you working directory you need to give it a unique name not already in use.
Changelog
---------
- 1.0.0.dev*
- First version, still in development
It is written and maintained for `Newsworthy <https://www.newsworthy.se/en/>`_, but could possibly come in handy for other people as well.
By `Journalism++ Stockholm <http://jplusplus.org/sv>`_.
Installing
----------
.. code:: bash
pip install newsworthy-charts
Using
-----
This module comes with two classes, `Chart` and `Storage` (and it's subclasses).
When using the Chart class, the generated chart will be saved as a local file:
.. code:: python3
from newsworthycharts import SerialChart
c = Chart(600, 800)
c.title = "Number of smiles per second"
c.xlabel = "Time"
c.ylabel = "Smiles"
c.caption = "Source: Ministry of smiles."
data_serie_1 = [("2008-01-01", 6.1), ("2009-01-01", 5.9), ("2010-01-01", 6.8)]
c.data.append(data_serie_1)
c.highlight = "2010-01-01"
c.render("test", "png")
You can use a _storage_ object to save file to
a specific location or cloud service:
.. code:: python3
from newsworthycharts import Chart
from newsworthycharts import S3Storage
s3 = S3Storage("my_bucket")
c = Chart(600, 800, storage=s3)
c.title = "Number of smiles per second"
c.xlabel = "Time"
c.ylabel = "Smiles"
c.caption = "Source: Ministry of smiles."
c.render("test", "png")
To store a file in a local folder, use the `LocalStorage` class:
.. code:: python3
from newsworthycharts import LocalStorage
storage = LocalStorage("/path/to/generated/charts")
Charts are styled using built-in or user-defined styles:
.. code:: python3
from newsworthycharts import Chart
# This chart has the newsworthy default style
c = Chart(600, 800, style="newsworthy")
# Style can also be the path to a style file (absolute or relative to current working directory)
c2 = Chart(600, 800, style="path/to/styles/mystyle.mplstyle")
To set up you own style, copy the build-in default: <https://github.com/jplusplus/newsworthycharts/blob/master/newsworthycharts/rc/newsworthy>
Newsworthycharts will look first among the predefined style files for the requested style, so if you have a custom style file in you working directory you need to give it a unique name not already in use.
Changelog
---------
- 1.0.0.dev*
- First version, still in development
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for newsworthycharts-1.0.0.dev3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17ff99c7671c9ea5cd810f29d0556e4cf9dc244eee25c24596e63e30ef73aab6 |
|
MD5 | 5e8efa44d4d84ac6fedc74dd47898946 |
|
BLAKE2b-256 | b9e22a6666e225e95b15edade75eb9d625d55268865e5f715e62d9ba4365d1d9 |
Close
Hashes for newsworthycharts-1.0.0.dev3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4accd54f1c9f69ac83bba1ef4f5e94cc885e1976f4a5b8b204ffec641670f265 |
|
MD5 | 11b1fd412ebcd5ce2807dba3a9ea48b3 |
|
BLAKE2b-256 | d29c552e47d1059c5b745a6032efdbc52f2e8bfd69dec90e8c8f0a1add343825 |