CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-plotly

An open-source interactive data visualization library for Python

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

Plotly

An open-source interactive data visualization library for Python that enables developers to create interactive, browser-based graphs and charts. Built on top of plotly.js, it offers over 30 chart types including scientific charts, 3D graphs, statistical charts, SVG maps, and financial charts with declarative, high-level APIs.

Package Information

  • Package Name: plotly
  • Language: Python
  • Installation: pip install plotly

Core Imports

import plotly

High-level plotting interface:

import plotly.express as px

Low-level graph objects:

import plotly.graph_objects as go

Figure factory for specialized charts:

import plotly.figure_factory as ff

I/O operations:

import plotly.io as pio

Subplot and utility functions:

import plotly.tools as tools

Basic Usage

import plotly.express as px
import pandas as pd

# Create sample data
df = pd.DataFrame({
    'x': [1, 2, 3, 4, 5],
    'y': [2, 4, 3, 5, 6],
    'category': ['A', 'B', 'A', 'B', 'A']
})

# Create a simple scatter plot
fig = px.scatter(df, x='x', y='y', color='category', 
                 title='Interactive Scatter Plot')
fig.show()

# Create a line chart with graph objects
import plotly.graph_objects as go

fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3, 4], y=[10, 11, 12, 13], mode='lines+markers'))
fig.update_layout(title='Line Chart with Graph Objects')
fig.show()

Architecture

Plotly provides multiple levels of abstraction for creating visualizations:

  • Express (px): High-level interface for rapid prototyping with sensible defaults
  • Graph Objects (go): Low-level interface for full customization and control
  • Figure Factory (ff): Specialized functions for complex statistical visualizations
  • I/O Module: Export/import capabilities for various formats (HTML, PNG, PDF, JSON)

The library integrates seamlessly with Jupyter notebooks, supports both online and offline rendering, and provides extensive customization options for publication-quality visualizations.

Capabilities

Express Plotting Interface

High-level plotting functions for rapid visualization creation with over 40 chart types including scatter, line, bar, histogram, box plots, geographic maps, 3D plots, and statistical charts.

def scatter(data_frame, x=None, y=None, color=None, size=None, **kwargs): ...
def line(data_frame, x=None, y=None, color=None, **kwargs): ...
def bar(data_frame, x=None, y=None, color=None, **kwargs): ...
def histogram(data_frame, x=None, y=None, color=None, **kwargs): ...
def box(data_frame, x=None, y=None, color=None, **kwargs): ...
def scatter_geo(data_frame, lat=None, lon=None, **kwargs): ...
def choropleth(data_frame, locations=None, color=None, **kwargs): ...
def scatter_3d(data_frame, x=None, y=None, z=None, **kwargs): ...

Express Plotting

Graph Objects Interface

Low-level figure construction with complete control over traces, layout, and styling using 50+ trace types and comprehensive layout options.

class Figure:
    def __init__(self, data=None, layout=None, **kwargs): ...
    def add_trace(self, trace, **kwargs): ...
    def update_layout(self, **kwargs): ...
    def show(self, **kwargs): ...

class Scatter:
    def __init__(self, x=None, y=None, mode=None, **kwargs): ...

class Bar:
    def __init__(self, x=None, y=None, **kwargs): ...

class Heatmap:
    def __init__(self, z=None, x=None, y=None, **kwargs): ...

Graph Objects

Figure Factory

Specialized figure creation functions for complex statistical and scientific visualizations including annotated heatmaps, dendrograms, distplots, and candlestick charts.

def create_annotated_heatmap(z, x=None, y=None, **kwargs): ...
def create_dendrogram(X, **kwargs): ...
def create_distplot(hist_data, group_labels, **kwargs): ...
def create_candlestick(open, high, low, close, dates, **kwargs): ...
def create_gantt(df, **kwargs): ...

Figure Factory

Input/Output Operations

Export and import functionality supporting multiple formats including HTML, static images (PNG, JPEG, PDF, SVG), and JSON serialization with Kaleido engine integration.

def show(fig, **kwargs): ...
def write_html(fig, file, **kwargs): ...
def write_image(fig, file, format=None, **kwargs): ...
def write_json(fig, file, **kwargs): ...
def read_json(file): ...
def to_html(fig, **kwargs): ...
def to_image(fig, format=None, **kwargs): ...

Input/Output

Color Utilities

Comprehensive color management with built-in color scales, palette generation, and color format conversion supporting sequential, diverging, cyclical, and qualitative color schemes.

def hex_to_rgb(hex_color): ...
def rgb_to_hex(rgb_tuple): ...
def make_colorscale(colors, **kwargs): ...
def sample_colorscale(colorscale, samplepoints, **kwargs): ...

# Color scale namespaces
sequential: ...  # Viridis, Plasma, Blues, etc.
diverging: ...   # RdBu, RdYlBu, Spectral, etc.
qualitative: ... # Set1, Set2, Pastel1, etc.
cyclical: ...    # IceFire, Edge, Phase, etc.

Color Utilities

Built-in Datasets

Sample datasets for learning and experimentation including iris, tips, gapminder, stocks, and other commonly used datasets in data science.

def iris(): ...
def tips(): ...
def gapminder(): ...
def stocks(): ...
def flights(): ...
def election(): ...

Built-in Datasets

Subplot and Utility Functions

Tools for creating subplot layouts, converting matplotlib figures, and other utility operations essential for complex figure composition and integration with other plotting libraries.

def make_subplots(rows=1, cols=1, subplot_titles=None, **kwargs): ...
def get_subplots(rows=1, columns=1, **kwargs): ...
def mpl_to_plotly(fig, resize=False, **kwargs): ...
def get_config_plotly_server_url(): ...

Subplot Tools

Types

# Core figure type returned by all plotting functions
class Figure:
    data: tuple  # Traces
    layout: dict  # Layout configuration
    
    def show(self, **kwargs): ...
    def update_layout(self, **kwargs): ...
    def add_trace(self, trace, **kwargs): ...
    def write_html(self, file, **kwargs): ...
    def write_image(self, file, **kwargs): ...

# Widget version for Jupyter notebooks
class FigureWidget(Figure):
    def __init__(self, data=None, layout=None, **kwargs): ...
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/plotly@6.3.x
Publish Source
CLI
Badge
tessl/pypi-plotly badge