Tool
Plot Rosetta
One figure, several plotting libraries. Pick a chart and up to three libraries to compare the code line by line. Every snippet uses the same data and was run before it was published; the image is what it produced.
Last run 2026-11-28 on Ubuntu 24.04.5 LTS: matplotlib 3.11.2, Plotly 7.2.0, gnuplot 6.0 patchlevel 0, ggplot2 3.4.4 (R 4.3.3), PLplot 5.15.0. Run log.
Chart
Libraries (up to 3)
Error bars
matplotlib Python

import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [2.1, 3.9, 6.2, 7.8, 10.1]
err = [0.3, 0.4, 0.5, 0.4, 0.6]
fig, ax = plt.subplots(figsize=(4, 3))
ax.errorbar(x, y, yerr=err, fmt="o", capsize=3)
ax.set_xlabel("Dose (mg)")
ax.set_ylabel("Response")
fig.tight_layout()
fig.savefig("errorbars-matplotlib.png", dpi=150)
matplotlib 3.11.2
Plotly Python

import plotly.graph_objects as go
x = [1, 2, 3, 4, 5]
y = [2.1, 3.9, 6.2, 7.8, 10.1]
err = [0.3, 0.4, 0.5, 0.4, 0.6]
fig = go.Figure(go.Scatter(x=x, y=y, mode="markers",
error_y=dict(type="data", array=err, visible=True)))
fig.update_layout(width=400, height=300, template="simple_white",
xaxis_title="Dose (mg)", yaxis_title="Response",
margin=dict(l=60, r=20, t=20, b=50))
fig.write_image("errorbars-plotly.png", scale=1.5)
Plotly 7.2.0
gnuplot gnuplot

set terminal pngcairo size 600,450 font "Sans,11"
set output "errorbars-gnuplot.png"
set xlabel "Dose (mg)"
set ylabel "Response"
set xrange [0.5:5.5]
$data << EOD
1 2.1 0.3
2 3.9 0.4
3 6.2 0.5
4 7.8 0.4
5 10.1 0.6
EOD
plot $data using 1:2:3 with yerrorbars pointtype 7 notitle
gnuplot 6.0 patchlevel 0
ggplot2 R

library(ggplot2)
d <- data.frame(x = 1:5,
y = c(2.1, 3.9, 6.2, 7.8, 10.1),
err = c(0.3, 0.4, 0.5, 0.4, 0.6))
p <- ggplot(d, aes(x, y)) +
geom_errorbar(aes(ymin = y - err, ymax = y + err), width = 0.15) +
geom_point(size = 2) +
labs(x = "Dose (mg)", y = "Response") +
theme_classic()
ggsave("errorbars-ggplot2.png", p, width = 4, height = 3, dpi = 150)
ggplot2 3.4.4
PLplot Python

import numpy as np
import plplot as pl
x = np.array([1.0, 2, 3, 4, 5])
y = np.array([2.1, 3.9, 6.2, 7.8, 10.1])
err = np.array([0.3, 0.4, 0.5, 0.4, 0.6])
pl.plsdev("pngcairo")
pl.plsfnam("errorbars-plplot.png")
pl.plspage(0, 0, 600, 450, 0, 0)
pl.plscolbg(255, 255, 255) # white background
pl.plscol0(1, 0, 0, 0) # colour 1 (axes, text) black
pl.plscol0(2, 31, 119, 180) # colour 2 (data) blue
pl.plinit()
pl.plcol0(1)
pl.plenv(0.5, 5.5, 0.0, 11.0, 0, 0)
pl.pllab("Dose (mg)", "Response", "")
pl.plcol0(2)
pl.plerry(x, y - err, y + err)
pl.plpoin(x, y, 4) # 4 = circle
pl.plend()
PLplot 5.15.0
Contour plot
matplotlib Python

import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
x = np.linspace(-3, 3, 61)
y = np.linspace(-3, 3, 61)
X, Y = np.meshgrid(x, y)
Z = np.exp(-(X**2 + Y**2) / 2) - 0.5 * np.exp(-((X - 1.5)**2 + (Y - 1)**2))
fig, ax = plt.subplots(figsize=(4, 3.2))
filled = ax.contourf(X, Y, Z, levels=12, cmap="viridis")
ax.contour(X, Y, Z, levels=12, colors="black", linewidths=0.4)
fig.colorbar(filled, ax=ax, label="z")
ax.set_xlabel("x")
ax.set_ylabel("y")
fig.tight_layout()
fig.savefig("contour-matplotlib.png", dpi=150)
matplotlib 3.11.2
Plotly Python

import numpy as np
import plotly.graph_objects as go
x = np.linspace(-3, 3, 61)
y = np.linspace(-3, 3, 61)
X, Y = np.meshgrid(x, y)
Z = np.exp(-(X**2 + Y**2) / 2) - 0.5 * np.exp(-((X - 1.5)**2 + (Y - 1)**2))
# ncontours is only a maximum; set the levels explicitly to get 12 bands
fig = go.Figure(go.Contour(z=Z, x=x, y=y, colorscale="Viridis",
contours=dict(start=-0.375, end=1.0, size=0.125),
colorbar=dict(title="z")))
fig.update_layout(width=400, height=320, template="simple_white",
xaxis_title="x", yaxis_title="y",
margin=dict(l=50, r=20, t=20, b=50))
fig.write_image("contour-plotly.png", scale=1.5)
Plotly 7.2.0
gnuplot gnuplot

set terminal pngcairo size 600,480 font "Sans,11"
set output "contour-gnuplot.png"
f(x, y) = exp(-(x**2 + y**2) / 2) - 0.5 * exp(-((x - 1.5)**2 + (y - 1)**2))
set xrange [-3:3]
set yrange [-3:3]
set isosamples 61, 61
set samples 61
set view map
set pm3d map
set palette defined (0 "#440154", 0.25 "#3b528b", 0.5 "#21918c", 0.75 "#5ec962", 1 "#fde725")
set contour base
set cntrparam levels incremental -0.375, 0.125, 1.0 # "levels 12" is only approximate
unset clabel
set xlabel "x"
set ylabel "y"
set cblabel "z"
splot f(x, y) with pm3d notitle, \
f(x, y) with lines lc rgb "black" lw 0.6 nosurface notitle
gnuplot 6.0 patchlevel 0
ggplot2 R

library(ggplot2)
d <- expand.grid(x = seq(-3, 3, length.out = 61), y = seq(-3, 3, length.out = 61))
d$z <- exp(-(d$x^2 + d$y^2) / 2) - 0.5 * exp(-((d$x - 1.5)^2 + (d$y - 1)^2))
p <- ggplot(d, aes(x, y, z = z)) +
geom_contour_filled(bins = 12) +
geom_contour(bins = 12, colour = "black", linewidth = 0.2) +
scale_fill_viridis_d(name = "z") +
coord_equal() +
theme_classic()
ggsave("contour-ggplot2.png", p, width = 5, height = 4, dpi = 150)
ggplot2 3.4.4
PLplot Python

import numpy as np
import plplot as pl
x = np.linspace(-3, 3, 61)
y = np.linspace(-3, 3, 61)
X, Y = np.meshgrid(x, y, indexing="ij") # PLplot wants z[ix][iy]
Z = np.exp(-(X**2 + Y**2) / 2) - 0.5 * np.exp(-((X - 1.5)**2 + (Y - 1)**2))
levels = np.linspace(Z.min(), Z.max(), 13)
pl.plsdev("pngcairo")
pl.plsfnam("contour-plplot.png")
pl.plspage(0, 0, 600, 480, 0, 0)
pl.plscolbg(255, 255, 255)
pl.plscol0(1, 0, 0, 0)
pl.plinit()
# viridis as cmap1 (five RGB control points)
pos = [0.0, 0.25, 0.5, 0.75, 1.0]
r = [0.267, 0.231, 0.129, 0.369, 0.992]
g = [0.004, 0.322, 0.569, 0.788, 0.906]
b = [0.329, 0.545, 0.549, 0.384, 0.145]
pl.plscmap1l(1, pos, r, g, b, [False] * 4)
pl.plcol0(1)
pl.plenv(-3, 3, -3, 3, 1, 0)
pl.plshades(Z, -3, 3, -3, 3, levels, 1.0, 1, 0.5, 1, None, None)
pl.plcol0(1)
pl.plbox("bcnst", 0, 0, "bcnstv", 0, 0)
pl.pllab("x", "y", "")
pl.plend()
PLplot 5.15.0
Log-log plot
matplotlib Python

import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
x = 10 ** np.arange(0, 4.01, 0.25)
y = 2 * x**1.5
fig, ax = plt.subplots(figsize=(4, 3))
ax.loglog(x, y, "o-")
ax.grid(True, which="both", linewidth=0.3)
ax.set_xlabel("Frequency (Hz)")
ax.set_ylabel("Power")
fig.tight_layout()
fig.savefig("loglog-matplotlib.png", dpi=150)
matplotlib 3.11.2
Plotly Python

import numpy as np
import plotly.graph_objects as go
x = 10 ** np.arange(0, 4.01, 0.25)
y = 2 * x**1.5
fig = go.Figure(go.Scatter(x=x, y=y, mode="lines+markers"))
fig.update_layout(width=400, height=300, template="simple_white",
xaxis=dict(type="log", title="Frequency (Hz)", showgrid=True),
yaxis=dict(type="log", title="Power", showgrid=True),
margin=dict(l=60, r=20, t=20, b=50))
fig.write_image("loglog-plotly.png", scale=1.5)
Plotly 7.2.0
gnuplot gnuplot

set terminal pngcairo size 600,450 font "Sans,11"
set output "loglog-gnuplot.png"
set logscale xy
set format x "10^{%L}"
set format y "10^{%L}"
set grid xtics ytics mxtics mytics lw 0.3
set xlabel "Frequency (Hz)"
set ylabel "Power"
set samples 17
plot [1:10000] '+' using (10**(($0) * 0.25)):(2 * (10**(($0) * 0.25))**1.5) with linespoints pointtype 7 notitle
gnuplot 6.0 patchlevel 0
ggplot2 R

library(ggplot2)
d <- data.frame(x = 10^seq(0, 4, by = 0.25))
d$y <- 2 * d$x^1.5
p <- ggplot(d, aes(x, y)) +
geom_line() +
geom_point() +
scale_x_log10() +
scale_y_log10() +
annotation_logticks() +
labs(x = "Frequency (Hz)", y = "Power") +
theme_classic()
ggsave("loglog-ggplot2.png", p, width = 4, height = 3, dpi = 150)
ggplot2 3.4.4
PLplot Python

import numpy as np
import plplot as pl
x = 10 ** np.arange(0, 4.01, 0.25)
y = 2 * x**1.5
pl.plsdev("pngcairo")
pl.plsfnam("loglog-plplot.png")
pl.plspage(0, 0, 600, 450, 0, 0)
pl.plscolbg(255, 255, 255)
pl.plscol0(1, 0, 0, 0)
pl.plscol0(2, 31, 119, 180)
pl.plinit()
pl.plcol0(1)
# axis = 30: logarithmic x and y with grid; PLplot plots log10 of the data
pl.plenv(0, 4, np.log10(y.min()), np.log10(y.max()), 0, 30)
pl.pllab("Frequency (Hz)", "Power", "")
pl.plcol0(2)
pl.plline(np.log10(x), np.log10(y))
pl.plpoin(np.log10(x), np.log10(y), 4)
pl.plend()
PLplot 5.15.0
Heatmap
matplotlib Python

import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
i, j = np.mgrid[0:10, 0:12]
Z = np.sin(i / 2) + np.cos(j / 3)
fig, ax = plt.subplots(figsize=(4.2, 3))
im = ax.imshow(Z, origin="lower", cmap="viridis", aspect="auto")
fig.colorbar(im, ax=ax, label="z")
ax.set_xlabel("Column")
ax.set_ylabel("Row")
fig.tight_layout()
fig.savefig("heatmap-matplotlib.png", dpi=150)
matplotlib 3.11.2
Plotly Python

import numpy as np
import plotly.graph_objects as go
i, j = np.mgrid[0:10, 0:12]
Z = np.sin(i / 2) + np.cos(j / 3)
fig = go.Figure(go.Heatmap(z=Z, colorscale="Viridis", colorbar=dict(title="z")))
fig.update_layout(width=420, height=300, template="simple_white",
xaxis_title="Column", yaxis_title="Row",
margin=dict(l=50, r=20, t=20, b=50))
fig.write_image("heatmap-plotly.png", scale=1.5)
Plotly 7.2.0
gnuplot gnuplot

set terminal pngcairo size 630,450 font "Sans,11"
set output "heatmap-gnuplot.png"
set palette defined (0 "#440154", 0.25 "#3b528b", 0.5 "#21918c", 0.75 "#5ec962", 1 "#fde725")
set xrange [-0.5:11.5]
set yrange [-0.5:9.5]
set samples 12
set isosamples 10
set xlabel "Column"
set ylabel "Row"
set cblabel "z"
# '++' yields a 12 x 10 grid of (x, y) points over the ranges set by samples/isosamples
set urange [0:11]
set vrange [0:9]
plot '++' using 1:2:(sin($2 / 2) + cos($1 / 3)) with image notitle
gnuplot 6.0 patchlevel 0
ggplot2 R

library(ggplot2)
d <- expand.grid(col = 0:11, row = 0:9)
d$z <- sin(d$row / 2) + cos(d$col / 3)
p <- ggplot(d, aes(col, row, fill = z)) +
geom_tile() +
scale_fill_viridis_c() +
labs(x = "Column", y = "Row") +
theme_classic()
ggsave("heatmap-ggplot2.png", p, width = 4.2, height = 3, dpi = 150)
ggplot2 3.4.4
PLplot Python

import numpy as np
import plplot as pl
i, j = np.mgrid[0:10, 0:12]
Z = np.sin(i / 2) + np.cos(j / 3)
img = Z.T.copy() # PLplot wants image[ix][iy]: columns first
pl.plsdev("pngcairo")
pl.plsfnam("heatmap-plplot.png")
pl.plspage(0, 0, 630, 450, 0, 0)
pl.plscolbg(255, 255, 255)
pl.plscol0(1, 0, 0, 0)
pl.plinit()
pos = [0.0, 0.25, 0.5, 0.75, 1.0]
r = [0.267, 0.231, 0.129, 0.369, 0.992]
g = [0.004, 0.322, 0.569, 0.788, 0.906]
b = [0.329, 0.545, 0.549, 0.384, 0.145]
pl.plscmap1l(1, pos, r, g, b, [False] * 4)
pl.plcol0(1)
pl.plenv(-0.5, 11.5, -0.5, 9.5, 0, 0)
pl.plimage(img, -0.5, 11.5, -0.5, 9.5, img.min(), img.max(), -0.5, 11.5, -0.5, 9.5)
pl.pllab("Column", "Row", "")
pl.plend()
PLplot 5.15.0
Where each library does it
| Task | matplotlib | Plotly | gnuplot | ggplot2 | PLplot |
|---|---|---|---|---|---|
| Figure size | plt.subplots(figsize=(w, h)) # inches | fig.update_layout(width=w, height=h) # pixels | set terminal pngcairo size w,h | ggsave(..., width = w, height = h) | plspage(0, 0, w, h, 0, 0) |
| Axis labels | ax.set_xlabel("x") | fig.update_layout(xaxis_title="x") | set xlabel "x" | labs(x = "x") | pllab("x", "y", "title") |
| Log axes | ax.loglog(x, y) | xaxis=dict(type="log") | set logscale xy | scale_x_log10() + scale_y_log10() | plenv(..., axis=30) and plot log10 values |
| Colour map | cmap="viridis" | colorscale="Viridis" | set palette defined (0 "#440154", ...) | scale_fill_viridis_c() | plscmap1l(1, pos, r, g, b, alt_hue_path) |
| Colour bar | fig.colorbar(mappable, label="z") | colorbar=dict(title="z") on the trace | drawn with pm3d and image; set cblabel "z" | legend added for the fill scale | plcolorbar() (not used in these examples) |
| Error bars | ax.errorbar(x, y, yerr=err) | error_y=dict(type="data", array=err) | plot ... using 1:2:3 with yerrorbars | geom_errorbar(aes(ymin = y - err, ymax = y + err)) | plerry(x, y - err, y + err) |
| Save to file | fig.savefig("f.png", dpi=150) | fig.write_image("f.png") # needs kaleido | set output "f.png" | ggsave("f.png", p, dpi = 150) | plsdev("pngcairo"); plsfnam("f.png") |
How the snippets are made
Each snippet is a complete program with its data written inline, so you can paste it and run it. They live in one folder per chart and are run together on Ubuntu by an automated job that fails if any of them errors or does not write its image. The versions above come from that run. Styling is kept close to each library's defaults, so the figures differ slightly in fonts and margins; the data, labels and colour map are the same.
Official documentation: matplotlib, Plotly, gnuplot, ggplot2 and PLplot.