class EInkStyler
A utility class providing styling configurations and color palettes optimized for e-ink displays with high contrast and minimal grayscale variations.
/tf/active/vicechatdev/e-ink-llm/graphics_generator.py
45 - 82
simple
Purpose
EInkStyler provides predefined color schemes, font sizes, and matplotlib style configurations specifically designed for e-ink displays. It offers high-contrast color palettes and chart styling that work well with the limited color range and refresh characteristics of e-ink screens. The class is designed as a configuration container with static methods and class-level constants, requiring no instantiation for normal use.
Source Code
class EInkStyler:
"""Styling configuration optimized for e-ink displays"""
# E-ink optimized color palette (high contrast)
COLORS = {
'black': '#000000',
'white': '#FFFFFF',
'gray_dark': '#333333',
'gray_medium': '#666666',
'gray_light': '#CCCCCC'
}
# Chart colors for e-ink (using patterns/shades)
CHART_COLORS = ['#000000', '#333333', '#666666', '#999999', '#CCCCCC']
# Font settings
FONT_SIZES = {
'title': 14,
'subtitle': 12,
'body': 10,
'caption': 8
}
@staticmethod
def get_eink_style():
"""Get matplotlib style configuration for e-ink displays"""
return {
'figure.facecolor': 'white',
'axes.facecolor': 'white',
'axes.edgecolor': 'black',
'axes.linewidth': 1.0,
'grid.color': '#CCCCCC',
'grid.linewidth': 0.5,
'text.color': 'black',
'axes.labelcolor': 'black',
'xtick.color': 'black',
'ytick.color': 'black'
}
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
bases: This parameter appears in the docstring but is not used in the class definition. The class has no __init__ method and is not designed to be instantiated. All functionality is provided through class attributes and static methods.
Return Value
The class itself returns nothing when referenced. The static method get_eink_style() returns a dictionary containing matplotlib style configuration parameters optimized for e-ink displays, with keys like 'figure.facecolor', 'axes.facecolor', etc., and their corresponding color/size values.
Class Interface
Methods
get_eink_style() -> dict
static
Purpose: Returns a dictionary of matplotlib style parameters optimized for e-ink displays
Returns: Dictionary with matplotlib rcParams keys and values for e-ink display optimization, including figure colors, axes properties, grid settings, and text colors
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
COLORS |
Dict[str, str] | High-contrast color palette with named colors (black, white, gray_dark, gray_medium, gray_light) mapped to hex color codes | class |
CHART_COLORS |
List[str] | List of five grayscale hex color codes ordered from darkest to lightest, suitable for multi-series charts on e-ink displays | class |
FONT_SIZES |
Dict[str, int] | Font size mappings for different text elements (title, subtitle, body, caption) optimized for e-ink readability | class |
Dependencies
matplotlib
Required Imports
import matplotlib.pyplot as plt
Usage Example
# Access color palette
black_color = EInkStyler.COLORS['black']
gray_color = EInkStyler.COLORS['gray_medium']
# Get chart colors for plotting
chart_colors = EInkStyler.CHART_COLORS
# Access font sizes
title_size = EInkStyler.FONT_SIZES['title']
body_size = EInkStyler.FONT_SIZES['body']
# Apply e-ink style to matplotlib
import matplotlib.pyplot as plt
eink_style = EInkStyler.get_eink_style()
plt.rcParams.update(eink_style)
# Create a plot with e-ink styling
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [1, 4, 9], color=EInkStyler.COLORS['black'])
ax.set_title('E-ink Optimized Plot', fontsize=EInkStyler.FONT_SIZES['title'])
plt.show()
Best Practices
- This class is designed as a static utility and does not need to be instantiated. Access all attributes and methods directly via the class name (e.g., EInkStyler.COLORS).
- Use the COLORS dictionary for consistent color application across e-ink visualizations to maintain high contrast.
- Apply get_eink_style() to matplotlib's rcParams before creating plots to ensure all charts are e-ink optimized.
- The CHART_COLORS list provides grayscale values in order from darkest to lightest, useful for multi-series charts on e-ink displays.
- Font sizes are calibrated for typical e-ink display resolutions; adjust if targeting specific screen sizes.
- The class maintains no state and has no side effects, making it safe to use across multiple threads or processes.
- All colors use hex format for compatibility with matplotlib and other visualization libraries.
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class ChartGenerator 59.7% similar
-
class PDFGenerator 52.7% similar
-
class CompactResponseFormatter 48.6% similar
-
function demo_graphics_generation 47.1% similar
-
function main_v59 46.7% similar