plot2html
Helping people publish beautiful automated reports that contribute to transparency, high quality monitoring and faster decision making
With this library, you can create static .html files with text and charts taking advantage of Google Charts API.
Installing this package (on the command line):
pip install plot2html
Python code:
# example data
import pandas as pd
temperature = pd.read_csv('https://raw.githubusercontent.com/rafatro/plot2html/main/tests/Temperature_London_Rome.csv',parse_dates=[0])
# date location tavg
# 2019-01-01 London 7.3
# 2019-01-02 London 3.7
# 2019-01-03 London 2.2
from plot2html import CreateReport
report = CreateReport("Example of plot2html Report")
report.text("<h2>Smart title you can create</h2>This is an example what what you can do with plot2html.")
options = {'title': 'Average temperature at London and Rome',
'hAxis': {'title': 'Date'},
'vAxis': {'title': 'Average Daily Temperature (Celsius)'},
'colors': ['#a52714', '#097138']
}
# We want a chart that shows each location as a different serie (each loacation should be a different line on the chart).
# Since the location is one column on the dataframe, we need to pivot the dataframe so each location becomes a column.
report.plot(data=temperature.pivot(index='date', columns='location', values='tavg').reset_index()
,x='date'
,y=['Rome','London']
,type='line'
,width='2-thirds'
,height=400
,options=options)
report.text('''This text is an explanation about the chart to the left.<br>
It shows data from <a href='https://meteostat.net/'>Meteostat</a>, that provides open source data about meteorology.<br>
You can see Rome temperatures follow the same trend as London's, because both cities are in the northern hemisphere, but Rome is a bit hotter, especialy on the summer.
''',width="third")
report.exporthtml("C:/Users/rafae/Desktop/plot2html/tests/index.html")
You will get this output:
Main arguments
Data: pandas DataFrame with the columns that are going to be used as either as the horizontal axis or the series of the chart.
x: name of the column that will be used as horizontal axis of the chart
y: name (or several names) of the columns that will be used as series of the chart.
type: either 'line' or 'column'. Other alternatives on development.
width: how much horizontal space of the screen is going to be occupied by the chart (or text). Possibilities: 'full' (default), 'half', 'third', '2-thirds' or 'quarter'.
height: height of the chart in pixels.
options: several parameters to be passed to Google Chart API, including title, axis title, colors, font size, annotations, gridlines, legend position etc. See all possibilities on Google Charts documentation site. But please note the notation is a bit different because requires the names of the parameters to be inside single quotes '. So, instead of options={hAxis:{title: 'Time',textStyle:{color: '#01579b',fontSize:20}}} use options={'hAxis':{'title': 'Time','textStyle':{'color': '#01579b','fontSize':20}}}
Enjoy!
Any feedback is welcome. This is just the beginning.
Metadata
Release files for plot2html 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| plot2html-0.0.10.tar.gz | 5.7 kB | Without provenance | Details for plot2html-0.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plot2html-0.0.10-py3-none-any.whl | Python 3 | none | any | Details for plot2html-0.0.10-py3-none-any.whl |
Total release size: 11.5 kB
Release files / plot2html-0.0.10.tar.gz
| Download URL | plot2html-0.0.10.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
988e10e314fc4e980aea967a93608d761099f2355b8bf5f0f6fe59e041af3d95
|
|
BLAKE2b-256 checksum How to use checksums |
52427995dbeedeece8117af41949d520cb2d6402e02ecfe179df3a0b38f5bb82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / plot2html-0.0.10-py3-none-any.whl
| Download URL | plot2html-0.0.10-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c6a435f82041949475e4974459761f035ad222387dd84a5dc2e404e9b81e3f4
|
|
BLAKE2b-256 checksum How to use checksums |
541d0a4c405028e0b81904308d321ae3af86a47b21e91068ca6d444004dddc81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Security for plot2html 0.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.