Skip to main content

ggplot2 interface to holoviews

Project description

ggviews: A ggplot2-style API for holoviews

Python License Documentation

ggviews is a comprehensive Python library that brings the beloved ggplot2 grammar of graphics to Python, built on top of holoviews for interactive visualizations. Create publication-quality plots with the intuitive, layered syntax that R users know and love.

✨ Recent Major Updates (v0.3.0)

  • 🎯 AUTOMATIC LEGENDS: Just like ggplot2 - aes(color='species') now creates legends automatically
  • 📊 STATISTICAL GEOMS: geom_boxplot(), geom_density() for comprehensive analysis
  • 🌈 COLORBREWER INTEGRATION: Professional publication palettes with scale_colour_brewer()
  • 🎛️ ADVANCED THEMING: theme() with element_text(), element_blank() for fine control
  • 🗺️ GEOGRAPHIC MAPPING: geom_map() with multiple projections and features
  • 🔄 COORDINATE SYSTEMS: coord_flip() for horizontal layouts
  • 🔥 2D VISUALIZATION: geom_tile(), geom_raster() for heatmaps and image data
  • 🔧 BUG FIXES: Resolved toolbar duplication, improved notebook display, fixed smooth placement

🎯 60% ggplot2 Coverage Achieved!

Features

Familiar Syntax: Use the same grammar of graphics you know and love from ggplot2 🔗 Method Chaining: Build plots incrementally with intuitive method chaining
🎨 Rich Geoms: Support for all major geom types (point, line, bar, histogram, etc.) 🎭 Themes: Beautiful default themes matching ggplot2's aesthetics 🎯 Faceting: Powerful facet_wrap and facet_grid for subplotting ⚡ Interactive: Leverage holoviews' interactive capabilities 📊 Extensible: Easy to extend with custom geoms and themes

Installation

pip install ggviews

For development installation:

git clone https://github.com/ggviews/ggviews.git
cd ggviews  
pip install -e ".[dev]"

Quick Start

from ggviews import ggplot, aes
import pandas as pd

# Load your data
df = pd.read_csv('your_data.csv')

# Create a beautiful plot with method chaining
(ggplot(df, aes(x='height', y='weight'))
 .geom_point(aes(color='species'), size=3, alpha=0.7)
 .geom_smooth(method='lm')
 .theme_minimal()
 .labs(
     title='Height vs Weight by Species',
     x='Height (cm)', 
     y='Weight (kg)'
 )
 .facet_wrap('~species'))

Core Concepts

Grammar of Graphics

ggviews implements the layered grammar of graphics:

  1. Data: Your pandas DataFrame
  2. Aesthetics: Map data to visual properties (x, y, color, size, etc.)
  3. Geometries: Visual representations of data (points, lines, bars, etc.)
  4. Scales: Control aesthetic mappings
  5. Themes: Overall visual styling
  6. Facets: Subplots based on data subsets

Method Chaining

Build plots incrementally:

plot = (ggplot(data)
        .geom_point()     # Add points
        .geom_line()      # Add lines  
        .theme_classic()  # Apply theme
        .labs(title='My Plot'))  # Add labels

Available Geoms

  • geom_point() - Scatter plots
  • geom_line() - Line plots
  • geom_bar() - Bar charts
  • geom_histogram() - Histograms
  • geom_boxplot() - Box plots
  • geom_violin() - Violin plots
  • geom_density() - Density plots
  • geom_smooth() - Smoothed conditional means
  • geom_area() - Area plots
  • geom_ribbon() - Ribbons/confidence bands
  • geom_tile() - Heatmaps
  • geom_text() - Text annotations

Themes

  • theme_minimal() - Clean, minimal theme
  • theme_classic() - Classic ggplot2 theme
  • theme_bw() - Black and white theme
  • theme_dark() - Dark theme
  • theme_void() - Completely blank theme

Scales

  • scale_color_manual() - Manual color scales
  • scale_color_discrete() - Discrete color scales
  • scale_color_continuous() - Continuous color scales
  • scale_x_continuous() / scale_y_continuous() - Continuous axis scales
  • scale_x_discrete() / scale_y_discrete() - Discrete axis scales

Faceting

Create subplots with:

  • facet_wrap('~variable') - Wrap subplots in a grid
  • facet_grid('row_var ~ col_var') - Grid of subplots

Examples

Basic Scatter Plot

ggplot(df, aes(x='x', y='y')).geom_point()

Colored by Category

ggplot(df, aes(x='x', y='y', color='category')).geom_point()

Multiple Layers

(ggplot(df, aes(x='x', y='y'))
 .geom_point()
 .geom_smooth())

Faceted Plot

(ggplot(df, aes(x='x', y='y'))
 .geom_point() 
 .facet_wrap('~group'))

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by Hadley Wickham's ggplot2
  • Built on the excellent holoviews library
  • Thanks to the broader Python data visualization community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ggviews-0.2.0.tar.gz (50.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ggviews-0.2.0-py3-none-any.whl (58.5 kB view details)

Uploaded Python 3

File details

Details for the file ggviews-0.2.0.tar.gz.

File metadata

  • Download URL: ggviews-0.2.0.tar.gz
  • Upload date:
  • Size: 50.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ggviews-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c1997b783f59720b5d52b3051439125e0d7306d6ef7e374530d4696f3f3d0e7b
MD5 fde6c40f03f1ead7edbe6a6736928292
BLAKE2b-256 a1897054888f4fb2bf9cadaedc1120844e463c130bfcea30735b77176caff22a

See more details on using hashes here.

File details

Details for the file ggviews-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ggviews-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 58.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ggviews-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab835122127297cdadea320ca74bc9eac055b0f062044f64f075811fde707cf1
MD5 582e69e30e0c253735abf51220692535
BLAKE2b-256 b4360851d702f58428debae19fddeaba2aa7bcbf7491f5b2fe77a467de288916

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page