CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-plotly

An open-source interactive data visualization library for Python

Pending
Overview
Eval results
Files

figure-factory.mddocs/

Figure Factory

Specialized figure creation functions for complex statistical and scientific visualizations. Figure Factory provides 19 high-level functions that generate sophisticated charts with minimal code, handling complex data transformations and styling automatically.

Capabilities

Statistical Visualizations

Advanced statistical chart creation functions for data analysis and scientific plotting.

def create_annotated_heatmap(z, x=None, y=None, annotation_text=None, 
                            colorscale='RdBu', font_colors=None, showscale=False, 
                            reversescale=False, **kwargs):
    """
    Create an annotated heatmap with text labels in each cell.
    
    Parameters:
    - z: 2D array-like, matrix values for heatmap colors
    - x: array-like, x-axis labels
    - y: array-like, y-axis labels  
    - annotation_text: 2D array-like, text for each cell (defaults to z values)
    - colorscale: str or list, color scale name or custom scale
    - font_colors: list of str, font colors for annotations
    - showscale: bool, whether to show color scale
    - reversescale: bool, whether to reverse color scale
    
    Returns:
    Figure: Plotly figure object with annotated heatmap
    """

def create_dendrogram(X, orientation='bottom', labels=None, colorscale=None, 
                     distfun=None, linkagefun=None, hovertext=None, 
                     color_threshold=None):
    """
    Create a dendrogram for hierarchical clustering visualization.
    
    Parameters:
    - X: 2D array-like, data matrix for clustering
    - orientation: str, dendrogram orientation ('bottom', 'top', 'left', 'right')
    - labels: array-like, labels for data points
    - colorscale: str or list, color scale for dendrogram branches
    - distfun: callable, distance function for clustering
    - linkagefun: callable, linkage function for clustering
    - color_threshold: float, threshold for coloring clusters
    
    Returns:
    Figure: Plotly figure object with dendrogram
    """

def create_distplot(hist_data, group_labels, bin_size=1.0, curve_type='kde', 
                   colors=None, rug_text=None, histnorm='probability density', 
                   show_hist=True, show_curve=True, show_rug=True):
    """
    Create a distribution plot with histograms, curves, and rug plots.
    
    Parameters:
    - hist_data: list of array-like, data arrays for each group
    - group_labels: list of str, labels for each data group
    - bin_size: float, histogram bin size
    - curve_type: str, curve type ('kde', 'normal')
    - colors: list of str, colors for each group
    - rug_text: list of array-like, hover text for rug plots
    - histnorm: str, histogram normalization
    - show_hist: bool, whether to show histograms
    - show_curve: bool, whether to show distribution curves
    - show_rug: bool, whether to show rug plots
    
    Returns:
    Figure: Plotly figure object with distribution plot
    """

def create_violin(data, data_header=None, group_header=None, colors=None, 
                 use_colorscale=False, group_stats=None, rugplot=True, 
                 sort=False, height=450, width=600, title='Violin Plot'):
    """
    Create violin plots for distribution visualization.
    
    Parameters:
    - data: 2D array-like, data matrix where columns represent groups
    - data_header: str, header for data values
    - group_header: str, header for group labels
    - colors: list of str, colors for each violin
    - use_colorscale: bool, whether to use continuous color scale
    - group_stats: dict, statistical information for each group
    - rugplot: bool, whether to include rug plot
    - sort: bool, whether to sort violins by median
    - height: int, figure height in pixels
    - width: int, figure width in pixels
    - title: str, figure title
    
    Returns:
    Figure: Plotly figure object with violin plots
    """

Financial Charts

Specialized functions for financial data visualization including candlestick and OHLC charts.

def create_candlestick(open, high, low, close, dates=None, direction='increasing', 
                      **kwargs):
    """
    Create a candlestick chart for financial data.
    
    Parameters:
    - open: array-like, opening prices
    - high: array-like, high prices
    - low: array-like, low prices
    - close: array-like, closing prices
    - dates: array-like, date/time values for x-axis
    - direction: str, price movement direction ('increasing', 'decreasing', 'both')
    
    Returns:
    Figure: Plotly figure object with candlestick chart
    """

def create_ohlc(open, high, low, close, dates=None, direction='increasing', 
               **kwargs):
    """
    Create an OHLC (Open-High-Low-Close) chart for financial data.
    
    Parameters:
    - open: array-like, opening prices
    - high: array-like, high prices  
    - low: array-like, low prices
    - close: array-like, closing prices
    - dates: array-like, date/time values for x-axis
    - direction: str, price movement direction
    
    Returns:
    Figure: Plotly figure object with OHLC chart
    """

Scientific Visualizations

Functions for specialized scientific and engineering visualizations.

def create_quiver(x, y, u, v, scale=1, arrow_scale=1, angle=None, **kwargs):
    """
    Create a quiver plot for vector field visualization.
    
    Parameters:
    - x: array-like, x coordinates of vector origins
    - y: array-like, y coordinates of vector origins
    - u: array-like, x components of vectors
    - v: array-like, y components of vectors
    - scale: float, scaling factor for vector lengths
    - arrow_scale: float, scaling factor for arrow sizes
    - angle: str, angle convention ('uv' or 'radians')
    
    Returns:
    Figure: Plotly figure object with quiver plot
    """

def create_streamline(x, y, u, v, density=1, angle=None, **kwargs):
    """
    Create a streamline plot for flow visualization.
    
    Parameters:
    - x: 2D array-like, x coordinates grid
    - y: 2D array-like, y coordinates grid  
    - u: 2D array-like, x components of flow vectors
    - v: 2D array-like, y components of flow vectors
    - density: float, streamline density factor
    - angle: str, angle convention
    
    Returns:
    Figure: Plotly figure object with streamline plot
    """

def create_trisurf(x, y, z, simplices=None, colormap=None, show_colorbar=True, 
                  edges_color='rgb(50, 50, 50)', title='Triangular Surface Plot', 
                  **kwargs):
    """
    Create a triangulated surface plot.
    
    Parameters:
    - x: array-like, x coordinates of vertices
    - y: array-like, y coordinates of vertices
    - z: array-like, z coordinates of vertices
    - simplices: array-like, triangulation connectivity (if None, computed automatically)
    - colormap: str or list, color scale for surface
    - show_colorbar: bool, whether to show color bar
    - edges_color: str, color for triangle edges
    - title: str, figure title
    
    Returns:
    Figure: Plotly figure object with triangulated surface
    """

Table and Matrix Visualizations

Functions for creating formatted tables and matrix displays.

def create_table(table_text, colorscale=None, font_colors=None, index=False, 
                index_title='', annotation_offset=0.45, height_constant=30, 
                hoverinfo='none', **kwargs):
    """
    Create a formatted table visualization.
    
    Parameters:
    - table_text: 2D array-like, table data with headers in first row
    - colorscale: str or list, background color scale for cells
    - font_colors: 2D array-like, font colors for each cell
    - index: bool, whether to include row indices
    - index_title: str, title for index column
    - annotation_offset: float, vertical offset for text annotations
    - height_constant: float, height scaling factor for rows
    - hoverinfo: str, hover information mode
    
    Returns:
    Figure: Plotly figure object with formatted table
    """

def create_2d_density(x, y, colorscale='Blues', ncontours=20, hist_color=(0, 0, 0.5), 
                     point_color=(0, 0, 0.5), point_size=2, title='2D Density Plot', 
                     height=600, width=600):
    """
    Create a 2D density plot with marginal histograms.
    
    Parameters:
    - x: array-like, x coordinates
    - y: array-like, y coordinates
    - colorscale: str or list, color scale for density contours
    - ncontours: int, number of contour levels
    - hist_color: tuple, RGB color for marginal histograms
    - point_color: tuple, RGB color for scatter points
    - point_size: float, size of scatter points
    - title: str, figure title
    - height: int, figure height in pixels
    - width: int, figure width in pixels
    
    Returns:
    Figure: Plotly figure object with 2D density plot
    """

Project Management and Specialized Charts

Functions for project management visualizations and specialized chart types.

def create_gantt(df, colors=None, index_col=None, show_colorbar=False, 
                reverse_colors=False, title='Gantt Chart', bar_width=0.2, 
                showgrid_x=False, showgrid_y=False, height=600, width=900, 
                tasks=None, task_names=None, data=None, **kwargs):
    """
    Create a Gantt chart for project timeline visualization.
    
    Parameters:
    - df: DataFrame, data with columns for tasks, start times, end times
    - colors: dict or list, color mapping for different task categories
    - index_col: str, column name to use for task identification
    - show_colorbar: bool, whether to show color bar
    - reverse_colors: bool, whether to reverse color order
    - title: str, chart title
    - bar_width: float, width of Gantt bars
    - showgrid_x: bool, whether to show x-axis grid
    - showgrid_y: bool, whether to show y-axis grid
    - height: int, figure height in pixels
    - width: int, figure width in pixels
    
    Returns:
    Figure: Plotly figure object with Gantt chart
    """

def create_bullet(ranges, measures, subtitles=None, titles=None, 
                 orientation='h', measure_colors=None, range_colors=None, 
                 scatter_options=None, **kwargs):
    """
    Create bullet charts for performance measurement.
    
    Parameters:
    - ranges: list of lists, background range values for each chart
    - measures: list of lists, performance measure values for each chart  
    - subtitles: list of str, subtitles for each chart
    - titles: list of str, main titles for each chart
    - orientation: str, chart orientation ('h' for horizontal, 'v' for vertical)
    - measure_colors: list of str, colors for measure markers
    - range_colors: list of str, colors for background ranges
    - scatter_options: dict, styling options for measure markers
    
    Returns:
    Figure: Plotly figure object with bullet charts
    """

def create_scatterplotmatrix(df, diag='scatter', size=10, height=500, width=500, 
                           title='Scatterplot Matrix', **kwargs):
    """
    Create a scatterplot matrix for multivariate data exploration.
    
    Parameters:
    - df: DataFrame, data for matrix with numeric columns
    - diag: str, diagonal plot type ('scatter', 'histogram', 'box')
    - size: float, marker size for scatter plots
    - height: int, figure height in pixels
    - width: int, figure width in pixels  
    - title: str, figure title
    
    Returns:
    Figure: Plotly figure object with scatterplot matrix
    """

Geographic and Specialized Visualizations

Additional specialized chart types for specific visualization needs.

def create_hexbin_mapbox(data_frame, lat=None, lon=None, color=None, 
                        agg_func=np.mean, gridsize=30, min_count=1, 
                        opacity=0.5, labels=None, color_continuous_scale=None, 
                        range_color=None, mapbox_style='open-street-map', 
                        zoom=8, center=None, animation_frame=None, **kwargs):
    """
    Create hexagonal binning visualization on mapbox.
    
    Parameters:
    - data_frame: DataFrame, data with lat/lon coordinates
    - lat: str, column name for latitude
    - lon: str, column name for longitude
    - color: str, column name for color aggregation
    - agg_func: callable, aggregation function for hexbins
    - gridsize: int, number of hexagons along x-axis
    - min_count: int, minimum points required per hexbin
    - opacity: float, hexbin opacity (0-1)
    - mapbox_style: str, mapbox style
    - zoom: int, initial map zoom level
    - center: dict, map center coordinates {'lat': float, 'lon': float}
    
    Returns:
    Figure: Plotly figure object with hexbin mapbox
    """

def create_ternary_contour(coordinates, values, pole_labels=['a', 'b', 'c'], 
                          interp_mode='cartesian', ncontours=None, 
                          colorscale='Viridis', showscale=True, **kwargs):
    """
    Create contour plots on ternary coordinate system.
    
    Parameters:
    - coordinates: array-like, ternary coordinates as 3-column array
    - values: array-like, values for contouring at each coordinate
    - pole_labels: list of str, labels for the three ternary axes
    - interp_mode: str, interpolation mode ('cartesian' or 'barycentric')  
    - ncontours: int, number of contour levels
    - colorscale: str or list, color scale for contours
    - showscale: bool, whether to show color scale
    
    Returns:
    Figure: Plotly figure object with ternary contour plot
    """

def create_parallel_coordinates(df, class_column=None, cols=None, 
                               dimensions=None, color=None, 
                               colorscale='Viridis', **kwargs):
    """
    Create parallel coordinates plot for multivariate data.
    
    Parameters:
    - df: DataFrame, data with numeric columns for parallel axes
    - class_column: str, column name for color encoding classes
    - cols: list of str, specific columns to include as dimensions
    - dimensions: list of dict, custom dimension configurations
    - color: str or array-like, values for color encoding
    - colorscale: str or list, color scale for lines
    
    Returns:
    Figure: Plotly figure object with parallel coordinates plot
    """

Usage Examples

import plotly.figure_factory as ff
import numpy as np
import pandas as pd

# Create annotated heatmap
z = [[1, 20, 30], [20, 1, 60], [30, 60, 1]]
x = ['Team A', 'Team B', 'Team C']  
y = ['Team A', 'Team B', 'Team C']

fig = ff.create_annotated_heatmap(z, x=x, y=y, colorscale='Viridis')
fig.update_layout(title='Team Performance Correlation')
fig.show()

# Create distribution plot
data1 = np.random.randn(200)
data2 = np.random.randn(200) + 2
data3 = np.random.randn(200) - 2

hist_data = [data1, data2, data3]
group_labels = ['Group 1', 'Group 2', 'Group 3']

fig = ff.create_distplot(hist_data, group_labels, bin_size=0.2)
fig.update_layout(title='Distribution Comparison')
fig.show()

# Create Gantt chart
df_gantt = pd.DataFrame([
    dict(Task="Job A", Start='2023-01-01', Finish='2023-01-15', Resource='Alice'),
    dict(Task="Job B", Start='2023-01-10', Finish='2023-01-25', Resource='Bob'), 
    dict(Task="Job C", Start='2023-01-20', Finish='2023-02-10', Resource='Alice')
])

fig = ff.create_gantt(df_gantt, colors={'Alice': 'rgb(220, 0, 0)', 
                                       'Bob': 'rgb(0, 0, 220)'})
fig.update_layout(title='Project Timeline')
fig.show()

# Create candlestick chart
dates = pd.date_range('2023-01-01', periods=30, freq='D')
open_prices = 100 + np.random.randn(30).cumsum()
high_prices = open_prices + np.random.uniform(0, 5, 30)
low_prices = open_prices - np.random.uniform(0, 5, 30)
close_prices = open_prices + np.random.randn(30)

fig = ff.create_candlestick(open_prices, high_prices, low_prices, 
                           close_prices, dates=dates)
fig.update_layout(title='Stock Price Chart', xaxis_rangeslider_visible=False)
fig.show()

Install with Tessl CLI

npx tessl i tessl/pypi-plotly

docs

color-utilities.md

datasets.md

express-plotting.md

figure-factory.md

graph-objects.md

index.md

io-operations.md

tools-utilities.md

tile.json