alandefreitas / matplotplusplus

Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
https://alandefreitas.github.io/matplotplusplus/
MIT License
4.3k stars 333 forks source link

Only the last subplot can be operated #51

Closed a00achild1 closed 4 years ago

a00achild1 commented 4 years ago

Hi, I am trying to use the subplot function recently. However, I found out that only the latest subplot can be operated(zoom in/out, ...) in the figure. This issue also happened in the example code.

Following is my environment: OS: Ubuntu 18.04 GNU: 5.2

It will be helpful if there is a solution for this issue. Thanks!

alandefreitas commented 4 years ago

Do you mean programmatically or interactively (with the mouse)? If you mean programmatically, do you have some code I can use to replicate the problem? If you mean interactively (with the mouse), this is a limitation of Gnuplot.

a00achild1 commented 4 years ago

I mean interactively. How about using the OpenGL? If OpenGL has no limitation of this, I would like to rebuild and try it.

alandefreitas commented 4 years ago

OpenGL itself doesn't have this limitation. You can run these examples to test it.

You'll see it's VERY efficient for interactive plots and you can also put it inside another application. For instance, you can use it to have plots in a Qt application. Or you can embed the plots in a game or something like that. It's like an ImGui for plots.

However, the OpenGL backend we really have is still very limited. So far, it can only create very simple line plots. It's mostly a boilerplate for some kind soul who wants to contribute in that area. It is a lot of work but it's much less work than creating the plots for your application from scratch unless something like qcustomplot solves your problem.

In practice, we need to maintain both backends in any case because OpenGL also has some limitations for scientific computing. For instance, it needs to be in the main thread so we need to keep calling draw constantly. Or call show and let it block the main thread.

This is usually ok, but does not generalize well for scientific computing. Running OpenGL outside the main thread would require another process with OpenGL and sockets to communicate what we want to plot. In fact, that's how the Qt terminal in gnuplot works. That's another stage anyway.

a00achild1 commented 4 years ago

I appreciate your detailed explanation! I will give it a try with OpenGL backend and think a way to apply it to my application which needs to process outside the main thread. Hope it could make my plots cleaner instead of showing lots of window.

Again, thanks for your help!