A Python package for visualizing event data as calendar heatmaps.
Project description
event-calplot
A Python library for creating beautiful calendar heatmaps with Plotly.
Features
- GitHub-style calendar heatmaps
- Customizable colors and styling
- Multi-language support (English, Korean)
- Built on Plotly for interactive visualizations
- Event highlighting
- Multi-year support
Installation
Using pip
pip install event-calplot
Using uv
uv add event-calplot
Quick Start
import numpy as np
import pandas as pd
from event_calplot import create_calendar_heatmap
# Create sample data
df = pd.DataFrame(
data={
"date": pd.date_range(start="2024-01-01", end="2024-12-31"),
"value": np.random.randint(0, 100, size=366),
}
)
# Event dates
event_dates = pd.to_datetime(
arg=[
"2024-01-01",
"2024-02-14",
"2024-03-01",
"2024-10-03",
"2024-10-09",
"2024-12-25",
]
)
# Create heatmap
fig = create_calendar_heatmap(
data=df,
date_col="date",
value_col="value",
year=2024,
min_color="#eff2f5",
max_color="#116329",
line_color="#cccccc",
event_dates=event_dates,
event_color="#b64f17",
)
fig.show()
Examples
Add Event
import numpy as np
import pandas as pd
from event_calplot import create_calendar_heatmap
# Create sample data
df = pd.DataFrame(
data={
"date": pd.date_range(start="2024-01-01", end="2024-12-31"),
"value": np.random.randint(0, 100, size=366),
}
)
# Event dates
event_dates = pd.to_datetime(
arg=[
"2024-01-01",
"2024-02-14",
"2024-03-01",
"2024-10-03",
"2024-10-09",
"2024-12-25",
]
)
# Create heatmap
fig = create_calendar_heatmap(
data=df,
date_col="date",
value_col="value",
year=2024,
min_color="#eff2f5",
max_color="#116329",
line_color="#cccccc",
event_dates=event_dates,
event_color="#b64f17",
)
fig.show()
API Reference
event-calplot
Create a calendar heatmap for a single year.
Parameters:
data(pd.DataFrame): DataFrame containing date and value columnsdate_col(str): Name of the date columnvalue_col(str): Name of the value columnyear(int): Year to visualizelanguage(Literal["en", "ko"], default="en"): Language for labelsmin_color(str, default="#eeeeee"): Color for minimum valuesmax_color(str, default="#678fae"): Color for maximum valuesline_color(str, default="#9e9e9e"): Color for month separator linesline_width(float, default=1.5): Width of month separator linesheight(int, default=250): Height of the plot in pixelshover_template(Optional[str], default=None): Custom hover templateevent_dates(Optional[List[pd.Timestamp]], default=None): Dates to highlightevent_color(str, default="#76cf61"): Color for event markers
Returns: plotly.graph_objs.Figure
create_multi_year_heatmap
Create calendar heatmaps for all years in the data.
Parameters:
data(pd.DataFrame): DataFrame containing date and value columnsdate_col(str): Name of the date columnvalue_col(str): Name of the value columnlanguage(Literal["en", "ko"], default="en"): Language for labels**kwargs: Additional arguments passed tocreate_calendar_heatmap
Returns: list[plotly.graph_objs.Figure]
Architecture
The package is organized into modular components:
preprocessing.py: Data preprocessing and transformation functionslayout.py: Plotly layout configurationtraces.py: Trace creation for heatmaps and linesheatmap.py: Main API functions
This modular design ensures:
- Each function has a single responsibility
- Easy testing and maintenance
- Clear separation of concerns
- Reusable components
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Q07K(Gyuhyeong Kim) (kgh0730@gmail.com)
Links
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file event_calplot-0.2.5.tar.gz.
File metadata
- Download URL: event_calplot-0.2.5.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5eb7ce0544ca42049a914e22e65474635771e3f67a177a115fec3346be2d671
|
|
| MD5 |
1729311af89390da4209505884608a56
|
|
| BLAKE2b-256 |
60b34ca58a278d152343a500e8bcef7586adcb1aed2f820a2a8dd369ad9ff62f
|
File details
Details for the file event_calplot-0.2.5-py3-none-any.whl.
File metadata
- Download URL: event_calplot-0.2.5-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
890ccb8336d6c3fa0588944a43603edda24d09eeda94036d354f9d055a1e564b
|
|
| MD5 |
28020a0dedcd130b2bd8e26c1a66daa3
|
|
| BLAKE2b-256 |
a14b9ea10e85473d6972105fadd4b17e430e08609cd705979b094cb26a430461
|