Example (or code snippet) for Matplotlib from a C++ application?

If I’m reading it correctly, it is possible for a C++ application to “call” the Matplotlib functionality included in VTK, transparently hiding the Python “plumbing” implied.

Is there any code snippet showing, for example, how to render a LaTeX math expression from C++ using such feature?

Let’s say, for example, a_{d} = \frac{f_d}{\gamma_d}

Thanks!

Here is an example :

But that’s Python code… I seem to recall I’ve read somewhere that VTK can do the Python for you. Maybe you can just print LaTeX math through vtkMathTextUtilities directly, without writing Python code?

BTW, note that for the moment I’m interested only in the rendering of LaTeX equations part only, not on plotting.

Indeed you can :
https://vtk.org/doc/nightly/html/classvtkMathTextUtilities.html#details

https://gitlab.kitware.com/vtk/vtk/blob/4c61381d5c8aa7d93d5085b67010db460d277d5d/Rendering/FreeType/Testing/Cxx/TestFreeTypeTextMapper.cxx

Thanks a lot! But, must I build it in some special way? For a quick check, I just changed the test function to be main() and compiled it reusing a standard CMakeLists.txt from other examples, then invoked it with the DejaVuSans.ttf font as argument, and the FreeType text did print, but the math was not parsed from LaTeX… must I add any special setting at either compile time (or at the link line)?

BTW, I do have vtkpython on the $PATH (just in case this code needs to invoke vtkpython, which I don’t know).

(EDIT: I added vtkRenderingMatplotlib in the find_package(VTK COMPONENTS … ) part of the CMakeLists.txt, but it doesn’t change the result --and yes, “libvtkRenderingMatplotlib-8.90.a” can be seen in the link line)

Look at the result: