Logo
AXION

Python SDK Utilities And Helpers

Utility Functions & Helpers

A collection of utility functions, shortcuts, and helpers for data manipulation, caching, and common operations in financial data analysis.

Import as: from axion import utils as axion_utils

Time Constants

Predefined string constants for natural language date references.

Date Constants

ConstantValueDescription
today'today'Current day reference
now'today'Current time reference
tomorrow'1 day from now'Next day reference
yesterday'1 day ago'Previous day reference
weekago'1 week ago'One week ago reference
weekfrom'1 week from today'One week from now reference
monthago'1 month ago'One month ago reference
monthfrom'1 month from now'One month from now reference
yearago'1 year ago'One year ago reference
yearfrom'1 year from now'One year from now reference

Frequency Constants

ConstantValueDescription
d, day'D'Daily frequency
w, week'W'Weekly frequency
m, month'M'Monthly frequency
y, year'Y'Yearly frequency
h, hour'H'Hourly frequency

Boolean Constants

true = TruePython boolean True
false = FalsePython boolean False

Caching Functions

Functions for persistent caching of data to disk to avoid repeated computation.

cache

cache(id, fn)

Caches the result of a function call. Returns cached result if it exists, otherwise calls the function and caches the result.

Parameters

  • id (str) - Unique identifier for the cache entry
  • fn (callable) - Function to call if cache doesn't exist

save

save(id, obj)

Manually saves an object to the cache directory.

Parameters

  • id (str) - Unique identifier for the cache entry
  • obj (any) - Object to save to cache

read

read(id)

Reads an object from the cache directory.

Parameters

  • id (str) - Unique identifier for the cache entry

scribe

scribe(df, id, cb)

Combines caching with concurrent processing using the work function.

Parameters

  • df (DataFrame) - DataFrame to process
  • id (str) - Cache identifier
  • cb (callable) - Callback function for processing rows
|

Cache Example

def fetch_expensive_data():
    return pd.DataFrame({'AAPL': [150, 151, 152]})

# First call - executes and caches
data = axion_utils.cache('stock_prices', fetch_expensive_data)

# Second call - loads from cache
cached_data = axion_utils.cache('stock_prices', fetch_expensive_data)

# Cache directory: ./.axion_cache/

Save & Read Example

# Manually save data
axion_utils.save('my_portfolio', {'AAPL': 150.25})

# Read it back
saved_data = axion_utils.read('my_portfolio')

Scribe Example

tickers_df = axion_utils.df([
    {'ticker': 'AAPL'}, {'ticker': 'GOOG'}
])

def fetch_data(row):
    return row['ticker'], {'price': 150.25}

results = axion_utils.scribe(tickers_df, 'stock_data', fetch_data)

Date Functions

Functions for parsing, converting, and manipulating dates.

Natural Language Date Parser

d(date_string)

Converts natural language date strings to YYYY-MM-DD format using parsedatetime library.

Parameters

  • date_string (str) - Natural language date

Returns

String in YYYY-MM-DD format or None if parsing fails

Date to Timestamp

to_timestamp(date)

Converts a date string in YYYY-MM-DD format to Unix timestamp.

Parameters

  • date (str) - Date in YYYY-MM-DD format

Nearest Trading Day

nearest_day(date_str, force=False)

Converts a date to the nearest trading day (Monday-Friday).

Parameters

  • date_str (str) - Date in YYYY-MM-DD format
  • force (bool) - If True, returns same date even if weekend

Weekend Handling

  • Saturday → Previous Friday
  • Sunday → Next Monday
  • Weekdays → Same day
|

Date Parsing Examples

today = axion_utils.d("today")
three_days_ago = axion_utils.d("3 days ago")
next_monday = axion_utils.d("next monday")

# With constants
last_month = axion_utils.d(axion_utils.monthago)

Timestamp & Trading Day

# Convert to timestamp
timestamp = axion_utils.to_timestamp("2024-01-15")

# Get nearest trading day
friday = axion_utils.nearest_day("2024-01-13")  # Saturday -> Friday
monday = axion_utils.nearest_day("2024-01-14")  # Sunday -> Monday

DataFrame Creation

Shortcut functions for creating and manipulating DataFrames.

DataFrame Shortcut

df(items)

Creates a pandas DataFrame from a list of dictionaries or other compatible data structures.

Parameters

  • items (list) - List of dictionaries or data to convert to DataFrame

DataFrame List Converter

pds(l)

Converts a 2D list of dictionaries into a 1D list of DataFrames.

Parameters

  • l (list) - 2D list of dictionaries

List Flattener

simmer(arr)

Flattens a 2D list into a 1D list.

Parameters

  • arr (list) - 2D list to flatten
|

Create DataFrame

stock_data = axion_utils.df([
    {'ticker': 'AAPL', 'price': 150.25},
    {'ticker': 'GOOG', 'price': 2815.50}
])

Convert Nested Data

api_data = [
    [{'metric': 'revenue', 'value': 100000}],
    [{'metric': 'revenue', 'value': 200000}]
]
dataframes = axion_utils.pds(api_data)

Flatten Lists

nested = [[1, 2, 3], [4, 5], [6, 7, 8]]
flattened = axion_utils.simmer(nested)
# [1, 2, 3, 4, 5, 6, 7, 8]

DataFrame Operations

Functions for filtering, merging, and transforming DataFrames.

Date Range Filter

resample(df, dates, col='time')

Filters DataFrame rows based on a date range string.

Parameters

  • df (DataFrame) - DataFrame to filter
  • dates (str) - String like "1 week ago 1 month ago"
  • col (str) - Column name containing dates

Column Value Filter

filter(df, col, items)

Filters DataFrame to include only rows where column values are in the specified list.

Parameters

  • df (DataFrame) - DataFrame to filter
  • col (str) - Column name to filter on
  • items (list) - List of values to include

Percentage Change Calculator

relativity(df, cols)

Calculates percentage change for specified columns and adds them as new columns.

Parameters

  • df (DataFrame) - DataFrame with time series data
  • cols (list) - List of column names to calculate percentage change for

Text to Zero Converter

convert_text_to_zero(value)

Converts text values, None, or NaN to zero, otherwise returns the numeric value.

Parameters

  • value (any) - Value to convert

List Deduplicator

dedup(lst)

Removes duplicate values from a list while preserving order.

Parameters

  • lst (list) - List with possible duplicates
|

Filter by Date

filtered = axion_utils.resample(
    data, 
    f"{axion_utils.weekago} {axion_utils.today}"
)

Filter by Values

tech_stocks = axion_utils.filter(
    stocks, 
    'sector', 
    ['Tech']
)

Calculate Returns

with_returns = axion_utils.relativity(
    prices, 
    ['price', 'volume']
)

Clean & Deduplicate

# Convert text to zero
cleaned = axion_utils.convert_text_to_zero('N/A')

# Remove duplicates
unique = axion_utils.dedup(['AAPL', 'GOOG', 'AAPL'])

DataFrame Combination

Functions for combining and merging multiple DataFrames in different ways.

Vertical Concatenation

stack(dfs)

Vertically concatenates multiple DataFrames with the same structure.

Parameters

  • dfs (list) - List of DataFrames to concatenate

Horizontal Merge

stitch(dfs, col='time')

Merges multiple DataFrames horizontally on a common column (inner join).

Parameters

  • dfs (list) - List of DataFrames to merge
  • col (str) - Column name to join on

Smart Merge with Renaming

snap(dfs, names=[], overwrite=[], col='time')

Merges DataFrames with intelligent column renaming and suffix management.

Parameters

  • dfs (list) - List of DataFrames to merge
  • names (list) - New names for columns
  • overwrite (list) - Columns to rename
  • col (str) - Merge column

Price Index Averager

indexed(prices)

Averages multiple price DataFrames (OHLCV) by timestamp to create a composite index.

Parameters

  • prices (dict) - Dictionary of ticker: DataFrame with OHLCV columns

Fact Averager

composite(dfs, joins=['fact', 'label'], col='value')

Combines and averages values from multiple fact/financial DataFrames.

Parameters

  • dfs (list) - List of DataFrames with financial facts
  • joins (list) - Columns to group by
  • col (str) - Column containing values to average

Fact Reshaper

contrast(dfs, joins, col="fact")

Reshapes multiple fact DataFrames into a single indexed DataFrame for graphing.

Parameters

  • dfs (list) - List of DataFrames with financial facts
  • joins (list) - Fact names to extract
  • col (str) - Column containing fact names
|

Vertical Stack

all_data = axion_utils.stack([q1_data, q2_data])

Horizontal Merge

combined = axion_utils.stitch([prices, economic])

Smart Merge

merged = axion_utils.snap(
    [company_a, company_b],
    names=['A', 'B'],
    overwrite=['revenue']
)

Create Index

index = axion_utils.indexed({
    'AAPL': aapl_df,
    'GOOG': goog_df
})

Average Estimates

consensus = axion_utils.composite([est1, est2])

Comparison Functions

Functions for comparing and analyzing differences between DataFrames.

Multi-DataFrame Comparer

compare(dfs, joins=['fact','value'])

Compares values across multiple DataFrames and calculates percentage differences.

Parameters

  • dfs (list) - List of DataFrames to compare
  • joins (list) - Columns to join and compare on

Set Difference Finder

difference(dfs, col)

Finds values in the first DataFrame that are not present in any subsequent DataFrame.

Parameters

  • dfs (list) - List of DataFrames
  • col (str) - Column name to compare

Set Overlap Finder

overlap(dfs, col)

Finds values that are present in all DataFrames.

Parameters

  • dfs (list) - List of DataFrames
  • col (str) - Column name to compare
|

Compare Estimates

comparison = axion_utils.compare([estimates_q1, estimates_q2])

Find Differences

added = axion_utils.difference([new, old], 'ticker')
removed = axion_utils.difference([old, new], 'ticker')

Find Overlap

common = axion_utils.overlap([fund_a, fund_b, fund_c], 'ticker')

Performance Analysis

Functions for analyzing price performance across multiple assets.

Top Gainers Finder

gainers(prices, frame, col='close', limit=500, relative=True, reverse=True)

Identifies assets with the highest price gains over a specified period.

Parameters

  • prices (dict) - Dictionary of ticker: DataFrame
  • frame (int) - Lookback period in rows
  • col (str) - Column to analyze
  • limit (int) - Maximum number of results
  • relative (bool) - Use percentage change or absolute change

Top Losers Finder

losers(prices, frame, col='close', relative=True, limit=500)

Wrapper function that calls gainers with reverse=False to find worst performers.

Parameters

  • prices (dict) - Dictionary of ticker: DataFrame
  • frame (int) - Lookback period in rows
  • col (str) - Column to analyze
  • limit (int) - Maximum number of results
  • relative (bool) - Use percentage change or absolute change
|

Find Gainers

top_gainers = axion_utils.gainers(
    prices, 
    frame=2, 
    limit=3
)

Find Losers

top_losers = axion_utils.losers(
    prices, 
    frame=2, 
    limit=3
)

Concurrency Function

Function for parallel processing of DataFrame rows.

Parallel Data Processor

work(df, cb, ref)

Processes DataFrame rows concurrently using a thread pool executor with progress bar.

Parameters

  • df (DataFrame) - DataFrame to process
  • cb (callable) - Callback function that processes each row
  • ref (dict) - Dictionary to store results (modified in place)
|

Parallel Processing

tickers = axion_utils.df([
    {'ticker': 'AAPL'},
    {'ticker': 'GOOG'},
    {'ticker': 'MSFT'},
])

def fetch_data(row):
    ticker = row['ticker']
    return ticker, {'price': 150.25}

results = {}
axion_utils.work(tickers, fetch_data, results)

Required Dependencies

These utility functions require the following Python packages:

Core Libraries

  • pandas - Data manipulation
  • numpy - Numerical operations
  • pickle - Object serialization
  • os - File system operations

Additional Libraries

  • parsedatetime - Natural language date parsing
  • datetime - Date/time manipulation
  • concurrent.futures - Thread pool executor
  • tqdm - Progress bars

Visualization Methods

A collection of visualization functions for financial and data analysis using Plotly.js. These methods provide interactive charts and graphs for data exploration and presentation.

visualize (Core Helper)

HELPERvisualize.visualize(fig)

Displays a Plotly figure object. This is the core visualization function used internally by all other methods. In Jupyter notebooks, this will render the chart inline. In scripts, it will open the chart in a browser.

Parameters

ParameterTypeRequiredDescription
figplotly.graph_objects.FigureRequiredPlotly figure object to display
|

Example

# Create a simple figure
import plotly.graph_objects as go
fig = go.Figure(data=go.Scatter(x=[1,2,3], y=[4,5,6]))

# Display it
visualize.visualize(fig)

visualize.cov()

FUNCTIONvisualize.cov(df)

Creates a heatmap visualization of the correlation matrix for numeric columns in a DataFrame. Uses the Viridis color scale and automatically handles the correlation calculation.

Parameters

ParameterTypeRequiredDescription
dfpandas.DataFrameRequiredDataFrame containing numeric columns for correlation analysis. Non-numeric columns are automatically ignored.
|

Example

import pandas as pd
from axion import visualize

# Create sample data
df = pd.DataFrame({
    'A': [1, 2, 3, 4, 5],
    'B': [2, 4, 6, 8, 10],
    'C': [5, 4, 3, 2, 1],
    'D': [1, 3, 5, 7, 9]
})

# Display correlation heatmap
visualize.cov(df)

visualize.candles()

FUNCTIONvisualize.candles(df)

Creates an interactive candlestick chart for financial price data with OHLC (Open, High, Low, Close) values. Perfect for stock prices, cryptocurrency data, or any time-series financial data.

Required DataFrame Columns

  • time - Time series data (dates/timestamps)
  • open - Opening price for each period
  • high - Highest price during each period
  • low - Lowest price during each period
  • close - Closing price for each period
|

Example

import pandas as pd
from axion import visualize

# Sample stock data
df = pd.DataFrame({
    'time': ['2024-01-01', '2024-01-02', '2024-01-03'],
    'open': [100, 102, 101],
    'high': [105, 103, 104],
    'low': [99, 101, 100],
    'close': [102, 101, 103]
})

# Display candlestick chart
visualize.candles(df)

visualize.line()

FUNCTIONvisualize.line(df, x, y, log=False)

Creates a line chart for time series or sequential data visualization. Supports logarithmic scaling for the x-axis.

Parameters

ParameterTypeDefaultDescription
dfpandas.DataFrame-DataFrame containing the data to plot
xstring-Column name for x-axis values (typically time/date)
ystring-Column name for y-axis values
logbooleanFalseUse logarithmic scale for x-axis
|

Examples

Basic Line Chart

# Basic line chart
df = pd.DataFrame({
    'date': ['2024-01-01', '2024-01-02', '2024-01-03'],
    'value': [10, 15, 13]
})
visualize.line(df, x='date', y='value')

Logarithmic X-Axis

# Line chart with logarithmic x-axis
df = pd.DataFrame({
    'x': [1, 10, 100, 1000],
    'y': [1, 2, 3, 4]
})
visualize.line(df, x='x', y='y', log=True)

visualize.pie()

FUNCTIONvisualize.pie(df, values, labels)

Creates a pie chart showing proportional distribution of categorical data. Each slice represents a category, and the size corresponds to the numeric values.

Parameters

ParameterTypeRequiredDescription
dfpandas.DataFrameRequiredDataFrame containing the data
valuesstringRequiredColumn name for pie slice sizes (numeric)
labelsstringRequiredColumn name for pie slice labels (categorical)
|

Example

# Market share data
df = pd.DataFrame({
    'company': ['Apple', 'Samsung', 'Google', 'Others'],
    'market_share': [45, 30, 15, 10]
})

visualize.pie(df, values='market_share', labels='company')

visualize.fit()

FUNCTIONvisualize.fit(df, x, y, log=False, hover=[], group=None)

Creates a scatter plot with an Ordinary Least Squares (OLS) trendline for regression analysis. The trendline shows the linear relationship between variables with confidence bands.

Parameters

ParameterTypeDefaultDescription
dfpandas.DataFrame-DataFrame containing the data
xstring-Column name for x-axis values (independent variable)
ystring-Column name for y-axis values (dependent variable)
logbooleanFalseUse logarithmic scale for x-axis
hoverlist[]List of column names to show in hover tooltips
groupstringNoneColumn name for color grouping (creates separate trendlines per group)
|

Examples

With Grouping

# Simple linear regression
df = pd.DataFrame({
    'x': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    'y': [2, 4, 5, 4, 5, 7, 8, 9, 10, 12],
    'category': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B']
})

# With grouping
visualize.fit(df, x='x', y='y', group='category', hover=['category'])

# Without grouping
visualize.fit(df, x='x', y='y')

visualize.scatter()

FUNCTIONvisualize.scatter(df, x, y, log=False, hover=[], group=None)

Creates a standard scatter plot for visualizing relationships between two variables. Supports grouping and hover data for enhanced data exploration.

Parameters

ParameterTypeDefaultDescription
dfpandas.DataFrame-DataFrame containing the data
xstring-Column name for x-axis values
ystring-Column name for y-axis values
logbooleanFalseUse logarithmic scale for x-axis
hoverlist[]List of column names to show in hover tooltips
groupstringNoneColumn name for color grouping
|

Examples

With Grouping

# Scatter plot with grouping and hover data
df = pd.DataFrame({
    'height': [150, 160, 170, 180, 155, 165, 175, 185],
    'weight': [50, 60, 70, 80, 55, 65, 75, 85],
    'gender': ['F', 'F', 'M', 'M', 'F', 'F', 'M', 'M'],
    'age': [25, 30, 35, 40, 28, 33, 38, 43]
})

visualize.scatter(df, x='height', y='weight', 
                  group='gender', hover=['age'])

Simple Scatter

# Simple scatter
visualize.scatter(df, x='height', y='weight')

visualize.bar()

FUNCTIONvisualize.bar(df, x, y)

Creates a vertical bar chart for categorical data comparison. Each bar represents a category, and the height represents the corresponding value.

Parameters

ParameterTypeRequiredDescription
dfpandas.DataFrameRequiredDataFrame containing the data
xstringRequiredColumn name for categories (x-axis)
ystringRequiredColumn name for values (bar heights)
|

Example

# Sales by product
df = pd.DataFrame({
    'product': ['A', 'B', 'C', 'D'],
    'sales': [1500, 2300, 1200, 3100]
})

visualize.bar(df, x='product', y='sales')

visualize.area()

FUNCTIONvisualize.area(df, x, y, group, sub="")

Creates a stacked area chart showing cumulative values over time by category. Great for visualizing composition changes over time.

Parameters

ParameterTypeDefaultDescription
dfpandas.DataFrame-DataFrame containing the data
xstring-Column name for x-axis (typically time/date)
ystring-Column name for y-axis values
groupstring-Column name for grouping/categories
substring""Subgroup identifier (currently unused)
|

Example

# Monthly sales by region
df = pd.DataFrame({
    'month': ['Jan', 'Jan', 'Feb', 'Feb', 'Mar', 'Mar'],
    'sales': [100, 150, 120, 180, 140, 200],
    'region': ['North', 'South', 'North', 'South', 'North', 'South']
})

visualize.area(df, x='month', y='sales', group='region')

visualize.heatmap()

FUNCTIONvisualize.heatmap(df, x, y, hover=[])

Creates a density heatmap showing the distribution of data points across two dimensions. The color intensity represents the density of points in each region.

Parameters

ParameterTypeDefaultDescription
dfpandas.DataFrame-DataFrame containing the data
xstring-Column name for x-axis values
ystring-Column name for y-axis values
hoverlist[]List of column names to show in hover tooltips
|

Example

# Create sample data with clusters
import numpy as np
import SEOMetadata from '@/components/SEOMetadata';
np.random.seed(42)
df = pd.DataFrame({
    'x': np.random.normal(0, 1, 1000),
    'y': np.random.normal(0, 1, 1000),
    'value': np.random.randn(1000)
})

visualize.heatmap(df, x='x', y='y', hover=['value'])

visualize.radar()

FUNCTIONvisualize.radar(df, values, labels)

Creates a radar chart for multivariate data visualization across multiple axes. Each axis represents a different variable, and the area shows the profile.

Parameters

ParameterTypeRequiredDescription
dfpandas.DataFrameRequiredDataFrame containing a single row of data
valuesstringRequiredColumn name containing the numeric values
labelsstringRequiredColumn name containing the axis labels
|

Example

# Product performance metrics
df = pd.DataFrame({
    'metric': ['Speed', 'Reliability', 'Cost', 'Quality', 'Support'],
    'score': [85, 92, 78, 95, 88]
})

visualize.radar(df, values='score', labels='metric')

visualize.barh()

FUNCTIONvisualize.barh(df, x, y)

Creates a horizontal bar chart, useful for comparing categories with long names or when you have many categories. Bars extend horizontally from the y-axis.

Parameters

ParameterTypeRequiredDescription
dfpandas.DataFrameRequiredDataFrame containing the data
xstringRequiredColumn name for values (bar lengths)
ystringRequiredColumn name for categories (y-axis labels)
|

Example

# Long category names
df = pd.DataFrame({
    'product': ['Enterprise License', 'Professional Edition', 
                'Standard Package', 'Basic Subscription'],
    'revenue': [150000, 85000, 45000, 20000]
})

visualize.barh(df, x='revenue', y='product')

visualize.spread()

FUNCTIONvisualize.spread(dfs, x, y)

Creates a composite chart showing two series and their difference (spread) as a bar chart. Perfect for pairs trading analysis or comparing two related time series.

Parameters

ParameterTypeRequiredDescription
dfslist of DataFramesRequiredList containing two DataFrames to compare
xstringRequiredCommon column name for merging and x-axis (usually time/date)
ystringRequiredColumn name for values in both DataFrames
|

Example

# Compare two correlated stocks
df1 = pd.DataFrame({
    'date': ['2024-01-01', '2024-01-02', '2024-01-03'],
    'price': [100, 102, 101]
})

df2 = pd.DataFrame({
    'date': ['2024-01-01', '2024-01-02', '2024-01-03'],
    'price': [98, 101, 103]
})

visualize.spread([df1, df2], x='date', y='price')

visualize.polls()

FUNCTIONvisualize.polls(df)

Creates a multi-line chart where each column in the DataFrame becomes a separate line series. The x-axis uses the DataFrame index, making it ideal for time series with multiple variables.

Parameters

ParameterTypeRequiredDescription
dfpandas.DataFrameRequiredDataFrame where each column becomes a line series. Index is used for x-axis.
|

Example

# Opinion polling over time
df = pd.DataFrame({
    'Candidate A': [45, 47, 46, 48, 50, 49],
    'Candidate B': [42, 41, 43, 42, 41, 43],
    'Undecided': [13, 12, 11, 10, 9, 8]
}, index=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'])

visualize.polls(df)

visualize.tree()

FUNCTIONvisualize.tree(df)

Creates a hierarchical treemap visualization for nested categorical data. Rectangles represent hierarchy levels, with size proportional to marketCap and color indicating pctchange.

Expected DataFrame Columns

  • sector - Top-level category (e.g., Technology, Healthcare)
  • industry - Mid-level category (e.g., Software, Biotech)
  • symbol - Leaf-level identifier (e.g., AAPL, MSFT)
  • marketCap - Size value (determines rectangle area)
  • pctchange - Color/hover data (red-green color scale)
  • lastsale - Additional hover data (last sale price)
|

Example

# Stock market sector visualization
df = pd.DataFrame({
    'sector': ['Tech', 'Tech', 'Tech', 'Health', 'Health'],
    'industry': ['Software', 'Software', 'Hardware', 'Biotech', 'Pharma'],
    'symbol': ['AAPL', 'MSFT', 'NVDA', 'GILD', 'PFE'],
    'marketCap': [2500000, 2100000, 800000, 700000, 180000],
    'pctchange': [2.5, 1.8, -0.5, 3.2, -1.1],
    'lastsale': [175.50, 380.25, 450.75, 85.30, 42.60]
})

visualize.tree(df)

visualize.graph()

FUNCTIONvisualize.graph(df, x, bars=[], lines=[], areas=[], title='', color=None)

Creates a comprehensive composite chart combining bars, lines, and areas on the same plot. Offers maximum flexibility for complex visualizations with multiple series types.

Parameters

ParameterTypeDefaultDescription
dfpandas.DataFrame-DataFrame containing all data
xstring-Column name for x-axis values
barslist[]List of column names for bar series
lineslist[]List of column names for line series
areaslist[]List of column names for area series
titlestring''Chart title
colorstringNoneColumn name for color grouping bars

Color Palette

shades_of_white = [
    'rgb(31, 119, 180)',  // blue
    'rgb(255, 127, 14)',  // orange
    'rgb(44, 160, 44)',   // green
    'rgb(214, 39, 40)',   // red
    'rgb(148, 103, 189)', // purple
    'rgb(140, 86, 75)',   // brown
    'rgb(255, 255, 255)',
    'rgb(245, 245, 245)',
    'rgb(235, 235, 235)',
    'rgb(235, 225, 225)',
    'rgb(235, 215, 215)',
    'rgb(235, 205, 205)',
]
|

Examples

Composite Chart

# Composite chart with bars and lines
df = pd.DataFrame({
    'date': ['2024-01-01', '2024-01-02', '2024-01-03'],
    'revenue': [1000, 1200, 1100],
    'profit': [200, 250, 230],
    'users': [500, 600, 650],
    'region': ['North', 'South', 'North']
})

visualize.graph(df, x='date', 
                bars=['revenue'], 
                lines=['profit', 'users'],
                title='Company Performance')

With Color Grouping

# With color grouping for bars
visualize.graph(df, x='date', 
                bars=['revenue'], 
                lines=['profit'],
                color='region',
                title='Performance by Region')