Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

ImPlot

ImPlot: 2D plots for Dear ImGui: lines, scatter, bars, shaded areas, heatmaps, histograms, pie charts, real-time data.

A plot lives between begin_plot() and end_plot(): the setup_* functions (axes, limits, legend) come first, then the plot_* functions. Run the app with immapp.run(..., with_implot=True), which creates ImPlot’s context.

In Python, the data are numpy arrays. ImPlot’s functions are templated on one numeric type, so the arrays of one call must share their dtype: convert them first (xs = xs.astype(ys.dtype)). Mismatched dtypes raise an error.

Upstream repository · The book’s page

Modules

In imgui_bundle (from imgui_bundle import implot):

Demos using it

The demos of the catalog that use it (the pictures link to their code and to the playground).

A parametric curve

A parametric curve

Turn the knobs, or click Random: the curve follows at once.

More

At every frame, the GUI function draws the plot with ImPlot and the knobs with imgui-knobs, and reads their values right there. No callbacks, no widget objects: that is the immediate mode.

Uses: ImPlot, knobs

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

A plot and markdown, in a few lines

A plot and markdown, in a few lines

A cosine wave moves in an ImPlot plot, under a text written in markdown.

More

Both are add-ons, activated in one call: immapp.run(gui, with_implot=True, with_markdown=True). A good start for a small app.

Uses: ImPlot

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Assets and add-ons

Assets and add-ons

Load images and icons from your assets folder, and use two add-ons: markdown and ImPlot.

More

A markdown editor with a live preview, and a pie chart whose values you can drag. Tick More info under each part to see how it is done. The add-ons are activated with immapp.AddOnsParams.

Uses: ImPlot

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

A beating heart

A beating heart

A heart curve drawn with ImPlot beats at the rate set by a knob from imgui-knobs.

More

A few lines of Python: a parametric curve, scaled by a pulse at each frame. Turn the knobs to change the heart rate, or its thickness.

Uses: ImPlot, knobs

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

A tiny neural network learns two spirals

A tiny neural network learns two spirals

Can 16 neurons tell two spirals apart? Watch a tiny neural network learn, live, as in the TensorFlow Playground.

More

Then read how it works, formula by formula, next to its numpy code.

Uses: ImPlot

Python: ▶︎ Run · Code

Simple harmonic motion

Simple harmonic motion

A mass on a spring, a pendulum, a vibrating string: they all follow the same equation.

More

It is the equation of simple harmonic motion (for the pendulum, at small angles). Adjust the mass and the spring stiffness, and watch how the motion changes.

Uses: ImPlot, knobs

Python: ▶︎ Run · Code

Double pendulum

Double pendulum

A double pendulum is a chaotic system: tiny changes in its initial conditions lead to wildly different trajectories.

More

Drag the angles to set initial positions, then release and watch chaos unfold.

Uses: ImPlot, knobs, toggles

Python: ▶︎ Run · Code

Fourier epicycles

Fourier epicycles

Any closed curve can be approximated by a sum of rotating circles (a Fourier series).

More

Adjust the number of circles to see how the approximation improves.

Uses: ImPlot, knobs, toggles

Python: ▶︎ Run · Code

Boids (flocks)

Boids (flocks)

A flock of birds emerges from three simple local rules, with no leader and no plan.

More

Each bird stays apart from its neighbors (separation), flies their way (alignment), and stays with them (cohesion). This is the boids model of Craig Reynolds (1986).

Uses: ImPlot, knobs, toggles

Python: ▶︎ Run · Code

Logistic map

Logistic map

A very simple equation, and yet it can lead to wildly different behaviors, up to chaos.

More

The logistic map, x(n+1) = r * x(n) * (1 - x(n)), models for example the growth of a population with limited resources. Depending on r, it is stable, periodic (in 2-cycles, 4-cycles, etc), or chaotic. Let’s explore this.

Uses: ImPlot, toggles

Python: ▶︎ Run · Code

Node editor: an image pipeline

Node editor: an image pipeline

An image flows through a graph of filters, and each node shows its result.

More

Change a parameter, and the nodes downstream follow at once. The patterns of imgui-node-editor for a real app: typed pins, links refused with a reason, a node created by dropping a link in empty space, menus, a group.

Uses: ImPlot, ImmVision, node editor, OpenCV

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

ImPlot: the interactive manual

ImPlot: the interactive manual

Every kind of plot of ImPlot, section by section, with the code of each beside it.

More

Lines, scatter, bars, heatmaps, histograms, real-time plots and more, in Python and C++. From Dear ImGui Explorer, the interactive manual for Dear ImGui and its libraries.

Uses: ImPlot

Python: ▶︎ Run · Code
C++: ▶︎ Run · Code

Context managers (imgui_ctx)

Context managers (imgui_ctx)

In Python, with imgui_ctx.begin("Window"): replaces a begin() / end() pair, and the end() can no longer be forgotten.

More

The same exists for child windows, menus, popups, tables, tabs, fonts and styles, and for ImPlot with implot_ctx. Open a section to try it and read its code. See the Python tips.

Uses: ImPlot

Python: ▶︎ Run · Code