Table of Contents
Plotting
It's quite difficult - practically impossible - to perceive data from rows and columns with numerical data. This holds true for complex (scientific) data; but also for much simpler data, e.g. temperature records over time. Graphical plots allow fast perception. That makes plots very important - also for debugging while development.
Plot Types
There are many plot types, you can select from. See https://datavizcatalogue.com/
Terminal / Command Line
Gnuplot is a portable command-line tool for creating plots.
Usually, comma seperated value (CSV) files are used as input, see comma separated values. But it's also possible to plot from binary data files.
C++
Following plotting libraries might be used for creating (debug) plot files.
First some meta results, which already give a good overview:
Here some (additional) links:
- sciplot
- Matplot++
- VTK
- PLplot
- Matplotlib-Cpp - requires python
- Immediate Mode Plotting (implot)
- Dear ImGui: https://github.com/ocornut/imgui
Python
A python script/program allowing interactive commands is better suited for experimenting/development.
However, C++ developers might use python when compiling their code as python module with bindings, e.g. with pybind11. Interface functions might utilize numpy or Eigen, see https://pybind11.readthedocs.io/en/stable/advanced/cast/eigen.html
In python, there are several plot libraries available:
- Matplotlib
- PyQtGraph - builds on Qt
- seaborn
i really like colored heatmaps:
Colormaps
Colormaps are used for visualizing or mapping mostly linear or grayscale data. IMHO, jet
is very appealing for linear or logarithmic data. matplotlibs' documentation shows many colormaps: https://matplotlib.org/stable/tutorials/colors/colormaps.html
From technical point of view, turbo
is an improved alternative for jet
, see https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
Other colormaps like viridis
, plasma
or inferno
provide perceptually uniform sequential lightness.
Here an interesting video on this topic: https://www.youtube.com/watch?v=xAoljeRJ3lU
In SDR and signal processing, such colormaps are used to visualize the power (or energy) in one single pixel to allow spectrogram plots, which already use x and y axes for time and frequency. For sure, there are usages in many other fields.
Cyclic colormaps
Circular data, e.g. phase values, should be treated special - as -180° equals +180°. Cyclic colormaps like twilight
or hsv
are for that case.
These colormaps are ideally viewed on circle like here: https://stackoverflow.com/questions/62531754/how-to-draw-a-hsv-color-wheel-using-matplotlib - and not on a ruler.