The same plot in 13 other libraries — Python: Altair, Bokeh, lets-plot, Matplotlib, Plotly, plotnine, Seaborn; R: ggplot2; Julia: Makie.jl; JavaScript: Chart.js, D3.js, Apache ECharts, MUI X Charts. Compare all 14 side by side: 3D Bar Chart for Categorical Comparison in Python, R, Julia and JavaScript.
A three-dimensional bar chart where bars rise from a 2D categorical grid, with height encoding the measured value. Two categorical axes define the grid position on the base plane while the vertical axis shows magnitude. This visualization extends the bar chart family into 3D space, making it effective for comparing values across two categorical dimensions simultaneously.

""" anyplot.ai
bar-3d-categorical: 3D Bar Chart for Categorical Comparison
Library: pygal 3.1.0 | Python 3.13.13
Quality: 81/100 | Created: 2026-05-15
"""
import os
import sys
# Temporarily remove current directory from path to avoid name collision with pygal package
_cwd = sys.path[0] if sys.path[0] else "."
if _cwd in sys.path:
sys.path.remove(_cwd)
import pygal
from pygal.style import Style
sys.path.insert(0, _cwd)
# Theme tokens
THEME = os.getenv("ANYPLOT_THEME", "light")
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
INK_MUTED = "#6B6A63" if THEME == "light" else "#A8A79F"
IMPRINT = ("#009E73", "#C475FD", "#4467A3", "#BD8233", "#AE3030", "#2ABCCD", "#954477")
# Data: Crop yield (kg/hectare) across five wheat varieties and four fertilizer treatments
varieties = ["Aster", "Borealis", "Crocus", "Delphi", "Ember"]
yields = {
"Control": [2850, 3120, 2640, 3380, 2970],
"Nitrogen+": [3540, 3820, 3290, 4050, 3650],
"Phosphorus+": [3180, 3460, 2980, 3720, 3310],
"NPK Blend": [3920, 4210, 3680, 4480, 4020],
}
# Style
custom_style = Style(
background=PAGE_BG,
plot_background=PAGE_BG,
foreground=INK,
foreground_strong=INK,
foreground_subtle=INK_MUTED,
colors=IMPRINT,
title_font_size=28,
label_font_size=18,
major_label_font_size=16,
legend_font_size=16,
value_font_size=14,
stroke_width=3,
)
# Plot
chart = pygal.Bar(
style=custom_style,
width=4800,
height=2700,
title="Crop Yield by Variety & Treatment · bar-3d-categorical · pygal · anyplot.ai",
x_title="Crop Variety",
y_title="Yield (kg / hectare)",
show_legend=True,
show_y_guides=True,
show_x_guides=False,
margin=80,
)
chart.x_labels = varieties
for treatment, values in yields.items():
chart.add(treatment, values)
# Save
chart.render_to_png(f"plot-{THEME}.png")
with open(f"plot-{THEME}.html", "wb") as f:
f.write(chart.render())
Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/bar-3d-categorical/pygal/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.
{
"spec_id": "bar-3d-categorical",
"language": "python",
"library": "pygal",
"page": "https://anyplot.ai/bar-3d-categorical/python/pygal",
"hub": "https://anyplot.ai/bar-3d-categorical",
"code_json": "https://api.anyplot.ai/specs/bar-3d-categorical/pygal/code",
"spec_json": "https://api.anyplot.ai/specs/bar-3d-categorical",
"render_light_png": "https://storage.googleapis.com/anyplot-images/plots/bar-3d-categorical/python/pygal/plot-light.png",
"render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/bar-3d-categorical/python/pygal/plot-dark.png",
"interactive_light_html": "https://storage.googleapis.com/anyplot-images/plots/bar-3d-categorical/python/pygal/plot-light.html",
"interactive_dark_html": "https://storage.googleapis.com/anyplot-images/plots/bar-3d-categorical/python/pygal/plot-dark.html",
"quality_score": 81.0,
"license": "MIT",
"guide": "https://anyplot.ai/llms.txt"
}Part of 3D Bar Chart for Categorical Comparison on anyplot.ai.