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

Rotor run-up monitor: vibration analysis

Rotor run-up monitor: vibration analysis

A simulated three-axis accelerometer sits on the bearing housing of a rotor whose speed sweeps up and down.

More

The dashboard shows what a vibration analyst would watch:

Uses: ImPlot, knobs, toggles, node editor

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

Health and wealth of nations, 1800 to 2100

Health and wealth of nations, 1800 to 2100

Each bubble is a country: income per person across, life expectancy up, population as the size, world region as the color.

More

Press Play and two centuries go by. Click a bubble to pin it and draw its path through time; pick other indicators for the axes.

Uses: ImPlot, spinners

Python: ▶︎ Run · Code

Medical imaging: a chest CT, its windows, a segmentation

Medical imaging: a chest CT, its windows, a segmentation

A real chest CT, explored as a radiologist would: its slices, its windows, and a region grown from a click.

More

Choose a window preset or drag its bounds on the histogram. Click a structure: the region grows across the slices, and the app measures it and shows it in 3D. A second tab finds the blood vessels of a retina. For research and teaching, not for diagnosis.

Uses: ImPlot, ImPlot3D, ImmVision, knobs, ImGuiKit, OpenCV

Python: ▶︎ Run · Code

Gravitational lensing: a ring, arcs, the Einstein Cross

Gravitational lensing: a ring, arcs, the Einstein Cross

A mass in the foreground bends the light of a galaxy behind it.

More

The left sky shows the galaxy as it is, the right one what we see through the lens. Drag the galaxy (yellow) and the lens (blue), turn the knobs, or start from a preset: an Einstein ring, two images, a giant arc, the Einstein Cross. The thin lines are the critical curve, where the magnification diverges, and its map in the source plane, the caustic: as the galaxy crosses it, images are born or merge. Hover a pixel of the observed sky to see where its light comes from.

Uses: ImPlot, knobs, toggles

Python: ▶︎ Run · Code

Power save when idle

Power save when idle

When nothing happens, Hello ImGui lowers the frame rate to spare the CPU: after 3 seconds, the live plot and the spinner become choppy.

More

Content that changes on its own says so with hello_imgui.set_item_is_live(), and keeps the full speed while it is visible. The idling settings are global.

Uses: ImPlot, toggles, spinners

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

Markdown tour

Markdown tour

Markdown rendered in an ImGui window: styled text, tables, code, images, math, diagrams, admonitions and more.

More

Each section shows its source, ready to copy. The page is a document: a table of contents, a search, headings that fold, and widgets between its renders (a live plot).

Uses: ImPlot

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

Markdown: a document with a table of contents and a search

Markdown as a document: a table of contents beside it, links between its sections, and a search (Ctrl+F).

More

Several renders and a section of widgets (a plot) share them, in one scroll area. The search also finds the text of the code blocks and of the collapsed sections. The headings fold.

Uses: ImPlot

Python: ▶︎ Run · Code
C++: ▶︎ 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

A GUI beside a Jupyter notebook

A GUI beside a Jupyter notebook

At 60 or 120 frames per second, a live GUI beside your Jupyter notebook while the cells run.

More

In async mode (immapp.nb.start()), another cell keeps computing, as fast as it can, between the frames: stream data into a plot, or train a model and tune it while it learns. The page explains both modes; its video trains a neural network live, its learning rate on a slider.

Page · Video

Touch screens (phones, tablets)

Touch screens (phones, tablets)

The gestures of a phone in the browser: a swipe, a tap, a long press, a pinch, the keyboard.

More

On a mobile or a tablet, Hello ImGui turns a finger into what its user expects: a swipe scrolls, a tap clicks, a held finger opens a context menu, a pinch scales the app (its font) or zooms a plot or an image, two fingers pan, and a keyboard button appears next to a text field.

Uses: ImPlot, ImmVision, ImGuiKit

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