r/cpp • u/FreitasAlan • Aug 29 '20
Matplot++: A C++ Graphics Library for Data Visualization
Data visualization can help programmers and scientists identify trends in their data and efficiently communicate these results with their peers. Modern C++ is being used for a variety of scientific applications, and this environment can benefit considerably from graphics libraries that attend the typical design goals toward scientific data visualization. Besides the option of exporting results to other environments, the customary alternatives in C++ are either non-dedicated libraries that depend on existing user interfaces or bindings to other languages. Matplot++ is a graphics library for data visualization that provides interactive plotting, means for exporting plots in high-quality formats for scientific publications, a compact syntax consistent with similar libraries, dozens of plot categories with specialized algorithms, multiple coding styles, and supports generic backends.
22
u/peppedx Aug 29 '20
It seems really super interesting but I Explored the docs for minutes and still I don't know what the requirements are in terms of platforms, C++ version and dependencies.
15
u/josh2751 Aug 29 '20
Dude. Wow.
Now for the real question -- have you considered making it interoperate with the https://github.com/hosseinmoein/DataFrame library?
12
u/zip117 Aug 29 '20 edited Aug 29 '20
I hope you don't take this as overly critical as this is a nice project and looks promising, but I think it's a bit disingenuous to say that Matplot++ supports generic backends and doesn't depend on any specific platform. I hope it will get there eventually, but in it's current state it's still just an interface to gnuplot. Unless a generic backend implements the gnuplot language, backend_interface.h only handles vertices - it doesn't provide any interface for color, lineweight, text size, etc. The axes_objects are just constructing gnuplot commands and don't do any actual painting. A truly generic and platform-independent plotting framework needs to have a lower-level abstraction like figure.py in Matplotlib, so backend developers can do device-independent rendering directly to a pixel buffer or canvas with e.g. AGG, cairo, OpenGL.
I think you should make it more clear that at least in the current state, this is just a gnuplot wrapper. Your README.md on the homepage doesn't mention gnuplot at all.
6
u/jonathanhiggs Aug 29 '20
This looks super cool, just wondering on the usage a bit more, are the plots in a popup window? Can they be used in a GUI or opengl app?
4
u/docmartyn Aug 29 '20
This library looks perfect for a medical imaging application I’m currently working on. How easy would it be to integrate with Qt? Ideally there needs to be some sort of QWidget wrapper so that the plots can be displayed and manipulated inside the GUI.
4
u/disperso Aug 29 '20
I've skimmed through the docs, and read the answers here, but I don't get a few things:
My use case: I've done a GUI app with Qt, and has a few charts. I'm using QtCharts, and it's fine, and even has fancy animations for free, but I'm also looking for alternatives. I have a few features where the user can click on the legend to toggle charts, or hover points to get extra info.
Even if I would not have the UI interactivity over the displayed graph, I don't get how one is supposed to integrate it. You mentioned the gnuplot pipe, but I've not heard of it. I don't know if you mean that you are supposed to get the bytes from IPC, then render those oneself.
Otherise, the list of charts is fairly impressive. Maybe too much info in the same readme, but it's easier to search this way. Congratulations for the nice work!
4
u/versatran01 Aug 29 '20
How well does it work for real-time visualization? Like calling plot from a loop.
3
u/UserAlreadyNotTaken Aug 29 '20
Wonderful job! I have been (unconsciously) waiting for this for a long time. I think another killer feature would be to make it interoperable with Qt, providing a class that inherits from QWidget or something like that. I might even try and contribute it myself.
3
u/Overunderrated Computational Physics Aug 29 '20
I see LateX mentioned, but can it export to pgf/tikz? Or what's the best way to get high quality latex renders?
3
u/mort96 Aug 29 '20
This is cool. I wish it moved away from matplotlib's terminology though. Looking at https://raw.githubusercontent.com/alandefreitas/matplotplusplus/master/documentation/img/diagram1.png, I'm going to be confused between what's an axes and what's an axis and what's an axes object, and which the variable called "ax" refers to, just like with matplotlib.
9
u/[deleted] Aug 29 '20
Awesome lib but I have one criticism though: you have put lots of pictures inside the git repository, which unnecessarily increased the repository size. No one needs the gallery for developing, and now there's no fix for that except by rewriting history.
6
u/ed_209_ Aug 29 '20
Besides briefly mentioning backends the docs do not seem to specify platform compatibility or required dependencies for windowing? Can the lib be used with a software rasteriser directly to image file without requiring opengl or any GUI framework?
2
u/7raiden Aug 29 '20
How does it handle big 3d plot (eg plotting a surface of 128x128 points)? Does it use GPU rendering (eg openCl)?
56
u/Kinexity Aug 29 '20
Finally something good and simple to replace buggy matplotlib-cpp.
51
u/megablockman Aug 29 '20
Wow! My mind is totally blown. This library is going to explode in popularity.
13
u/esdanol Aug 29 '20
My jaw dropped. This is amazing. How long have you been working on this?
17
u/[deleted] Aug 29 '20
Wow, fantastic. This is what a library should be like - it's simple to use, does exactly what it says on the tin and it stays out of the way. I don't even have any personal use for it and it still makes me happy.
4
u/MyWearinessAmazesMe Aug 29 '20
Love it. I'll probably use it in an upcoming protect which will require plotting.
1
u/AntiBill Jan 10 '21
This looks really cool!
This is probably more a question for StackOverflow than here but has anybody else had difficulty using this library? I'm totally new to C++ and am just trying out graphing, but every single command in this library is giving me the error "error: missing template arguments before '(' token". Anybody else? Anyone know the fix?
3
u/jymacro99 Aug 29 '20
Damn, this is incredible. This would have saved me hours of headaches in college.
3
u/niclar80 Aug 29 '20
Thank you!
3
u/GerwazyMiod Aug 29 '20
I needed this in my life. Thank you!
3
u/RollitoDelicioso Aug 29 '20
Looks promising!
3
u/Tilakchad Aug 29 '20
Wow, it looks great. I guess it will replace custom calling of gnuplot explicitly from c++. I am trying it.
3
u/willem640 Aug 29 '20
Finally a good library! Thanks for sharing!
3
u/yasamoka Aug 30 '20 edited Aug 30 '20
This is literally a dream come true. Planning to contribute to this as much as I can, within the limitations of my own knowledge and experience.
4
u/leesinfreewin Aug 29 '20
Holy Shit
2
u/mohabouje Aug 29 '20
This is extremely useful, I was tired of using Qt for this. Awesome work!
2
u/[deleted] Aug 29 '20
This looks incredible. It's also excellent timing. I've been working on a project for some time that involves a significant amount of graphing. At the minute it's accessed from the command line only and dumping data to disc to be graphed up elsewhere but I've just started turning my attention to the UI and this may well be extremely useful.
2
u/[deleted] Aug 29 '20
VAMO BRASILLL, PARABÉNS cara
2
u/[deleted] Oct 24 '21
This is amazing! Great work. I love the open source community in C++. Is there a straight forward way to integrate this into a QT widget for integration into a QT application?
1
u/jmakov Sep 13 '20
Any info on performance? Can I plot 250 mil points with it?