A Python library to generate beautiful, clean charts in premium visual styles
Project description
Clean Charts
clean-charts is a lightweight, premium Python library designed to generate beautiful, publication-quality data visualizations (inspired by modern publication designs like The Economist).
Featuring right-aligned axes, custom date boundaries, distinct line colors, automatic overlap-avoiding label placement, and dynamic scaling for varying canvas resolutions, clean-charts makes it effortless to create presentation-ready visualizations.
Key Features
- Premium Aesthetics: Light cream-gray backgrounds, minimal gridlines, elegant typography, and consistent padding.
- Time-Series Line Charts (
plot_time_series):- Right-aligned Y-axes.
- Automatically identifies date/time columns and handles multiple value series.
- Generates custom color gradients or uses a refined default palette.
- Intelligently spaces dates and years on the X-axis to prevent label overlap.
- Smart label placement that directly labels lines at their endpoints (avoiding messy legends).
- Horizontal Bar Charts (
plot_barh_chart):- Left-aligned categories and titles.
- Top-aligned numeric ticks with custom suffixes (e.g.,
%,x,kg). - Values labeled inside/outside the end of each bar.
- Responsive Scaling: All text, line-weights, and paddings scale proportionally based on target width and height.
Installation
Install the package directly from the local directory:
pip install clean-charts
Quick Start
1. Line Chart (Time Series)
By default, calling plot_time_series without any arguments uses a built-in sample dataset mapping automobile sales types from 2020 to 2025.
from clean_charts import plot_time_series
# Recreate a standard landscape chart (1000x562)
plot_time_series(
output_path="chart_landscape.png",
aspect_ratio="landscape",
title="Europe",
subtitle="Sales of Chinese-made cars, % of total"
)
Output Example:
2. Horizontal Bar Chart
Draw a horizontal bar chart with categories and value labels. If no data is provided, it uses a default survey dataset.
from clean_charts import plot_barh_chart
# Create a clean horizontal bar chart with custom title and suffix
plot_barh_chart(
output_path="chart_barh.png",
title="Super Bowl Viewer Interest",
subtitle="Are you planning to watch the game this Sunday?",
value_suffix="%"
)
Output Example:
Customizing Data & Advanced Usage
Custom Time-Series Data
You can supply your own pandas.DataFrame containing a date/time column and one or more value columns. The library automatically parses the datetime column and maps all other numeric columns as lines.
import pandas as pd
from clean_charts import plot_time_series
# 1. Prepare your dataset
data = pd.DataFrame({
"Day": pd.date_range("2026-05-01", periods=10, freq="D"),
"Active Users": [120, 150, 190, 240, 220, 250, 270, 310, 340, 320],
"Signups": [15, 22, 35, 40, 28, 30, 32, 45, 52, 48]
})
# 2. Plot with custom color gradient and day-level label frequency
plot_time_series(
data=data,
output_path="daily_stats.png",
title="Daily Server Growth",
subtitle="Active users and registrations in May 2026",
label_frequency="day", # Supported: "year", "quarter", "month", "week", "day", "hour", "minute", "second"
start_color="#006400", # Dark Green gradient start
end_color="#ffd700", # Gold gradient end
)
Custom Horizontal Bar Chart Data
Pass a custom pandas.DataFrame where the first column contains the labels (string) and the second column contains the numeric values.
import pandas as pd
from clean_charts import plot_barh_chart
# 1. Prepare your categories and values
df = pd.DataFrame({
'Category': ['Apples', 'Bananas', 'Cherries', 'Dates', 'Elderberries', 'Figs', 'Grapes', 'Honeydew'],
'Sales (tons)': [400, 350, 300, 450, 120, 210, 520, 180]
})
# 2. Render horizontal bar chart
plot_barh_chart(
data=df,
output_path="fruit_sales.png",
title="Fruit Performance Analysis",
subtitle="Total sales volume by item to optimize supply chain distribution",
value_suffix=" t",
color="#1f77b4" # Hex color code for the bars
)
API Reference
plot_time_series
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
pd.DataFrame |
None |
DataFrame containing datetime column and value series columns. If None, uses built-in default data. |
output_path |
str |
"chart.png" |
File path to save the generated image. |
width |
int |
1000 |
Target width of the image in pixels. |
height |
int |
562 |
Target height of the image in pixels. |
aspect_ratio |
str |
None |
Predefined aspect ratio: "square" (or "1:1"), "landscape" (or "2:1"), "vertical" (or "1:2"). Overrides width/height if set. |
title |
str |
None |
Main title text displayed in bold at the top left. |
subtitle |
str |
None |
Subtitle text displayed below the title. |
start_color |
str |
None |
Hex color code for the first line series gradient boundary. |
end_color |
str |
None |
Hex color code for the last line series gradient boundary. |
label_frequency |
str |
"year" |
X-axis label frequency: "year", "quarter", "month", "week", "day", "hour", "minute", "second". |
scale_text |
bool |
True |
Automatically scale text fonts, line widths, and pad widths proportionally. |
plot_barh_chart
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
pd.DataFrame |
None |
DataFrame with column 0 as category strings and column 1 as numeric values. If None, uses built-in survey data. |
output_path |
str |
"bar_chart.png" |
File path to save the generated image. |
width |
int |
600 |
Target image width in pixels. |
height |
int |
None |
Target image height in pixels. Auto-sized dynamically based on the number of categories if None. |
aspect_ratio |
str |
None |
Predefined aspect ratio: "square"/"1:1", "landscape"/"2:1", "vertical"/"1:2". |
title |
str |
None |
Main title text displayed in bold. |
subtitle |
str |
None |
Subtitle text displayed below the title. |
color |
str |
None |
Hex color for the bars. If None, defaults to the config's line color. |
bar_padding |
float |
0.35 |
Fraction of bar slot left as gap between bars (0.0 to 1.0). |
value_suffix |
str |
"" |
String appended to value labels and axis ticks (e.g. "%"). |
scale_text |
bool |
True |
Automatically scale text fonts and margins proportionally. |
Global Customization
You can import and change the global configuration styling variables dynamically:
import clean_charts.config as config
from clean_charts import plot_time_series
# Modify styling tokens globally
config.BACKGROUND_COLOR = "#ffffff" # Set background to pure white
config.GRID_COLOR = "#eaeaea" # Lighten gridlines
config.AXIS_COLOR = "#333333" # Dark charcoal axis
plot_time_series(
title="Custom White Theme",
output_path="white_theme_chart.png"
)
Available config variables (in clean_charts.config):
BACKGROUND_COLOR(default:"#f4f3f0")GRID_COLOR(default:"#dcdbd7")AXIS_COLOR(default:"#000000")TITLE_COLOR(default:"#111111")SUBTITLE_COLOR(default:"#444444")LINE_COLOR(default:"#000000")
Examples & Development
Run Samples
To generate all sample charts showing various aspect ratios, gradients, and custom frequencies, run the provided sample script:
python generate_sample.py
Running Tests
To run the unit tests suite:
python -m unittest tests/test_plot.py
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
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 clean_charts-0.2.3.tar.gz.
File metadata
- Download URL: clean_charts-0.2.3.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
832c6962a054397bbc6a26a0a33eec9cda35797d969290e9792b740080ba3984
|
|
| MD5 |
9f178e25e2dc1fa7466eef5fb1562df7
|
|
| BLAKE2b-256 |
92eb41b202783e99266a62d7158ad85b36792a890898cc52793437ee0e031c9e
|
File details
Details for the file clean_charts-0.2.3-py3-none-any.whl.
File metadata
- Download URL: clean_charts-0.2.3-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbbb083f0effafebccfe91b581dcb7d6707104c52a5e423caa82f8fe4178d162
|
|
| MD5 |
63352b1d23e1c3b091c3888f78aaa795
|
|
| BLAKE2b-256 |
f36b50393680717ff1d35f3d650b20ab5542e36a8fc4ecd32d3b48b9aa24ba49
|