Geometric Objects (Geoms)¶
Geoms are the geometric objects that represent data in your plot.
Basic Geoms¶
- class ggviews.geoms.geom_point(mapping=None, data=None, size=6, alpha=1.0, color=None, shape='circle', **kwargs)[source]¶
Bases:
GeomLayerScatter plot points
- Parameters:
mapping – Aesthetic mappings (aes object)
data – Data for this layer (overrides ggplot data)
size – Point size
alpha – Transparency (0-1)
color – Point color
shape – Point shape
**kwargs – Additional parameters
- class ggviews.geoms.geom_line(mapping=None, data=None, color=None, size=2, alpha=1.0, linetype='solid', **kwargs)[source]¶
Bases:
GeomLayerLine plots
- Parameters:
mapping – Aesthetic mappings
data – Data for this layer
color – Line color
size – Line width
alpha – Transparency
linetype – Line type (‘solid’, ‘dashed’, ‘dotted’)
**kwargs – Additional parameters
- class ggviews.geoms.geom_bar(mapping=None, data=None, stat='count', color=None, fill=None, alpha=1.0, width=0.8, **kwargs)[source]¶
Bases:
GeomLayerBar charts
- Parameters:
mapping – Aesthetic mappings
data – Data for this layer
stat – Statistical transformation (‘count’ or ‘identity’)
color – Bar border color
fill – Bar fill color
alpha – Transparency
width – Bar width
**kwargs – Additional parameters
- class ggviews.geoms.geom_histogram(mapping=None, data=None, bins=30, alpha=1.0, fill=None, color=None, **kwargs)[source]¶
Bases:
GeomLayerHistograms
- Parameters:
mapping – Aesthetic mappings
data – Data for this layer
bins – Number of bins or bin edges
alpha – Transparency
fill – Fill color
color – Border color
**kwargs – Additional parameters
- class ggviews.geoms.geom_area(mapping=None, data=None, stat='identity', position='identity', alpha=0.7, fill=None, color=None, size=1, **kwargs)[source]¶
Bases:
GeomLayerArea plots
Draws an area plot where the area under the curve is filled. Useful for showing cumulative values or stacked areas.
- Parameters:
mapping – Aesthetic mappings (x, y, fill, color, group, alpha)
data – Data for this layer
stat – Statistical transformation (‘identity’ or ‘count’)
position – Position adjustment (‘identity’, ‘stack’, ‘fill’)
alpha – Transparency (0-1)
fill – Fill color
color – Outline color
size – Outline width
**kwargs – Additional parameters
Examples
geom_area(aes(x=’year’, y=’value’)) geom_area(aes(x=’year’, y=’value’, fill=’category’)) geom_area(position=’stack’) # Stacked areas
- class ggviews.geoms.geom_smooth(mapping=None, data=None, method='loess', se=True, color=None, fill=None, alpha=1.0, **kwargs)[source]¶
Bases:
GeomLayerSmoothed conditional means
- Parameters:
mapping – Aesthetic mappings
data – Data for this layer
method – Smoothing method (‘lm’ for linear, ‘loess’ for local regression)
se – Show confidence interval
color – Line color
fill – Confidence band color
alpha – Transparency
**kwargs – Additional parameters
Statistical Geoms¶
- class ggviews.geom_boxplot.geom_boxplot(mapping=None, data=None, width=0.9, outlier_alpha=1.0, outlier_color=None, outlier_size=1.5, coef=1.5, **kwargs)[source]¶
Bases:
GeomLayerBox and whisker plots
Creates box-and-whisker plots showing the distribution of a continuous variable, optionally grouped by a categorical variable.
- Parameters:
mapping – Aesthetic mappings (aes object)
data – Data for this layer
width – Box width (default: 0.9)
outlier_alpha – Transparency for outliers (default: 1.0)
outlier_color – Color for outliers (default: None)
outlier_size – Size for outliers (default: 1.5)
coef – Whisker length coefficient (default: 1.5)
**kwargs – Additional parameters
Examples
# Basic boxplot geom_boxplot(aes(y=’value’))
# Grouped boxplot geom_boxplot(aes(x=’group’, y=’value’))
# Customized geom_boxplot(aes(x=’group’, y=’value’, fill=’group’), width=0.5)
- class ggviews.geom_density.geom_density(mapping=None, data=None, bw='scott', kernel='gaussian', n=512, adjust=1.0, trim=False, **kwargs)[source]¶
Bases:
GeomLayerKernel density estimation plots
Computes and displays kernel density estimates, which are smoothed versions of histograms.
- Parameters:
mapping – Aesthetic mappings (aes object)
data – Data for this layer
bw – Bandwidth for kernel density estimation (‘scott’, ‘silverman’, or float)
kernel – Kernel to use (‘gaussian’, ‘tophat’, ‘epanechnikov’, etc.)
n – Number of points to evaluate density at (default: 512)
adjust – Adjustment factor for bandwidth (default: 1.0)
trim – Whether to trim the density curve to data range
**kwargs – Additional parameters
Examples
# Basic density plot geom_density(aes(x=’value’))
# Multiple densities by group geom_density(aes(x=’value’, fill=’group’), alpha=0.5)
# Customized bandwidth geom_density(aes(x=’value’), bw=0.5, kernel=’gaussian’)
2D Visualization¶
- class ggviews.geom_tile.geom_tile(mapping=None, data=None, width=None, height=None, **kwargs)[source]¶
Bases:
GeomLayerRectangles with specified positions and dimensions
Creates heatmap-like visualizations using rectangles (tiles). Each tile represents a data point with x, y coordinates and can be colored by a third variable.
- Parameters:
mapping – Aesthetic mappings (aes object)
data – Data for this layer
width – Tile width (default: auto-calculated)
height – Tile height (default: auto-calculated)
**kwargs – Additional parameters
Examples
# Basic heatmap geom_tile(aes(x=’x_var’, y=’y_var’, fill=’z_var’))
# Custom tile size geom_tile(aes(x=’x’, y=’y’, fill=’value’), width=1, height=1)
- class ggviews.geom_tile.geom_raster(mapping=None, data=None, interpolate=False, **kwargs)[source]¶
Bases:
geom_tileHigh performance rectangular tiles for large datasets
Similar to geom_tile but optimized for large regular grids. Better performance for image-like data.
- Parameters:
mapping – Aesthetic mappings (aes object)
data – Data for this layer
interpolate – Whether to interpolate between points
**kwargs – Additional parameters
Examples
# Large heatmap geom_raster(aes(x=’x’, y=’y’, fill=’value’))
# Image-like data geom_raster(aes(x=’x’, y=’y’, fill=’intensity’), interpolate=True)
Geographic Visualization¶
- class ggviews.geom_map.geom_map(mapping=None, data=None, map_type='points', projection=None, features=['coastlines'], alpha=0.7, color=None, fill=None, size=6, **kwargs)[source]¶
Bases:
GeomLayerGeographic map layer
Creates geographic visualizations using points, polygons, or choropleth maps. Requires geoviews and cartopy for full functionality.
- Parameters:
mapping – Aesthetic mappings (aes object)
data – Data for this layer (should contain lat/lon or geometry)
map_type – Type of map (‘points’, ‘polygons’, ‘choropleth’, ‘world’)
projection – Map projection (default: PlateCarree)
features – List of map features to add (‘coastlines’, ‘borders’, ‘land’, ‘ocean’)
alpha – Transparency (0-1)
color – Point/line color
fill – Fill color for polygons
size – Point size
**kwargs – Additional parameters
Examples
# World map with points geom_map(aes(x=’longitude’, y=’latitude’), map_type=’points’)
# Choropleth map geom_map(aes(fill=’population’), map_type=’choropleth’)
# Custom projection geom_map(map_type=’world’, projection=’Mollweide’)
Additional Geoms¶
Additional geometric objects for ggviews
This module implements additional geoms commonly used in ggplot2 including ribbon, violin, text, and more specialized plot types.
- class ggviews.additional_geoms.geom_errorbar(mapping=None, data=None, width=0.1, color='black', size=1, alpha=1, **kwargs)[source]¶
Bases:
GeomLayerError bars
Display error bars showing uncertainty or variation in data.
- Parameters:
mapping – Aesthetic mappings (x, ymin, ymax, width, color)
data – Data for this layer
width – Width of error bar caps
color – Error bar color
size – Line width
alpha – Transparency
**kwargs – Additional parameters
Examples
geom_errorbar(aes(x=’treatment’, ymin=’lower’, ymax=’upper’)) geom_errorbar(aes(x=’x’, ymin=’y-se’, ymax=’y+se’), width=0.2)
- class ggviews.additional_geoms.geom_label(mapping=None, data=None, label_padding=0.25, label_r=0.15, fill='white', color='black', **kwargs)[source]¶
Bases:
geom_textText labels with background boxes
Similar to geom_text but with background rectangles for better readability.
- Parameters:
mapping – Aesthetic mappings (x, y, label, color, fill)
data – Data for this layer
label_padding – Padding around text
label_r – Corner radius of label box
fill – Background fill color
color – Text color
**kwargs – Additional parameters inherited from geom_text
- class ggviews.additional_geoms.geom_ribbon(mapping=None, data=None, alpha=0.5, fill=None, color=None, size=0, **kwargs)[source]¶
Bases:
GeomLayerRibbon plots (confidence bands, error ribbons)
Creates ribbons between ymin and ymax values, commonly used for confidence intervals around trend lines.
- Parameters:
mapping – Aesthetic mappings (x, ymin, ymax, fill, color, alpha)
data – Data for this layer
alpha – Transparency (0-1)
fill – Fill color
color – Border color
size – Border width
**kwargs – Additional parameters
Examples
geom_ribbon(aes(x=’x’, ymin=’lower’, ymax=’upper’), alpha=0.3) geom_ribbon(aes(x=’x’, ymin=’y-se’, ymax=’y+se’, fill=’group’))
- class ggviews.additional_geoms.geom_text(mapping=None, data=None, nudge_x=0, nudge_y=0, size=12, color='black', alpha=1, fontface='plain', family='Arial', hjust=0.5, vjust=0.5, check_overlap=False, **kwargs)[source]¶
Bases:
GeomLayerText annotations
Add text labels to plots at specified positions.
- Parameters:
mapping – Aesthetic mappings (x, y, label, color, size, angle)
data – Data for this layer
nudge_x – Horizontal adjustment
nudge_y – Vertical adjustment
size – Text size
color – Text color
alpha – Text transparency
fontface – Font face (‘plain’, ‘bold’, ‘italic’)
family – Font family
hjust – Horizontal justification (0=left, 0.5=center, 1=right)
vjust – Vertical justification (0=bottom, 0.5=center, 1=top)
check_overlap – Whether to avoid overlapping text
**kwargs – Additional parameters
Examples
geom_text(aes(x=’x’, y=’y’, label=’name’)) geom_text(aes(x=’x’, y=’y’, label=’value’), nudge_y=0.1)
- class ggviews.additional_geoms.geom_violin(mapping=None, data=None, trim=True, scale='area', alpha=0.7, fill=None, color=None, **kwargs)[source]¶
Bases:
GeomLayerViolin plots
Shows the distribution of data through kernel density estimation on each side, creating a violin-like shape.
- Parameters:
mapping – Aesthetic mappings (x, y, fill, color)
data – Data for this layer
trim – Trim the violin to data range
scale – How to scale violins (‘area’, ‘count’, ‘width’)
alpha – Transparency
fill – Fill color
color – Border color
**kwargs – Additional parameters