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, but could possibly come in handy for other people as well.
Installing
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:
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:
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:
from newsworthycharts import LocalStorage
storage = LocalStorage("/path/to/generated/charts")
Charts are styled using built-in or user-defined styles:
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
Hashes for newsworthycharts-1.0.0.dev9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb668c83a78a793b7ba9b72be65f667554b6cbbeebd2b24b6ca4d74b768a0090 |
|
MD5 | ffd3d5d580b2c10ce723726b664496d9 |
|
BLAKE2b-256 | 7a7d9062a8c039d374f73d7d49ff1e7bd93367a4a5bf937260193e7c2b897f17 |
Hashes for newsworthycharts-1.0.0.dev9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c70a8e2123d7ed12ce42b7cf6251efd18523df24f9e7f7c2ff784bb2df9f3b0e |
|
MD5 | 103435735e7e067a85755ce9eba42e28 |
|
BLAKE2b-256 | 8bb690d75d0c4d2177f03159a1ba9abbf29b4c8deb19e274032f0a65ce1eb77d |