# Plotting in Zig: A gnuplot wrapper with similar api as matplotlib from python

**URL:** <https://ziggit.dev/t/plotting-in-zig-a-gnuplot-wrapper-with-similar-api-as-matplotlib-from-python/18657>\
**Category:** Showcase\
**Tags:** llm\
**Created:** [December 1, 2026, 12:37pm UTC](https://ziggit.dev/t/plotting-in-zig-a-gnuplot-wrapper-with-similar-api-as-matplotlib-from-python/18657 "2026-12-01T12:37:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![halfdisposal](https://ziggit.dev/letter_avatar_proxy/v4/letter/h/c5a1d2/32.png) [@halfdisposal](https://ziggit.dev/u/halfdisposal)\
**Post date:** [December 1, 2026, 12:37pm UTC](https://ziggit.dev/t/plotting-in-zig-a-gnuplot-wrapper-with-similar-api-as-matplotlib-from-python/18657/1 "2026-12-01T12:37:36Z")

</div>

# A Gnuplot Wrapper with Python’s Matplotlib like Bindings:

* * *

This is a personal project that I initially didn’t intended on publishing, but thought might be useful to wierdos like me. As obvious its a gnuplot wrapper with bindings similar to matplotlib. Since I am relatively new to zig and inteded to use this project as a learning project where I learn the heres and theres of the language while building something meaningful, so its highly personalized and unoptimized (_just a disclaimer_).

### Example

```zig
const std = @import("std");
const gnuplot = @import("gnuplot");
const Io = std.Io;

const Figure = gnuplot.Figure;

pub fn main(init: std.process.Init) !void {
    const io = init.io;
    const gpa = init.gpa;

    var fig = Figure.init(io, gpa, .{.term = "qt", .width = 1024, .height = 750});
    defer fig.deinit();

    const x = [_]i32{1, 2, 3, 4, 5};
    const y = [_]i32{1, 2, 3, 4, 5};
    const y2: @Vector(5, f64) = .{1.0, 2.0, 3.0, 4.0, 5.0};
    try fig.xlabel("x", .{});
    try fig.ylabel("y", .{});
    try fig.grid();
    try fig.plot(&x, &y, .{.label = "line 1"});
    try fig.scatter(&x, &y, .{.label = "points 1", .color = "red"});
    try fig.bar(y2, .{.label = "bar"});
    try fig.show();
}

```

Its based on lazy evaluation where the commands are stored in ArrayLists, and are not evaluated until `show` or `savefig` is called.

Recently added `imshow` and currently working on 3D ploting and animation(though no going well).

Hope someone finds it interesting, here is the repo link [https://github.com/halfdisposal/gnuplot-zig](https://github.com/halfdisposal/gnuplot-zig).

### Supported Zig versions

Tested on the latest zig version zig-0.18.0-dev.146+35accc06e

### AI / LLM usage disclosure

The main idea and execution including most of things are done by me myself. AI is used for writings the tests (too lazy to do them manually) and sometimes to figure out random errors I can’t understand and where repitative code is required.

_first post btw_
