alandefreitas / matplotplusplus

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

Subplot disappears upon resizing of figure #348

Open mhered opened 1 year ago

mhered commented 1 year ago

Bug category

Describe the bug

Steps to Reproduce

Code:


auto ax1 = matplot::subplot(2, 1, 1);
matplot::plot(ax1, x, y1);
matplot::title(ax1, "Subplot 1");

auto ax2 = matplot::subplot(2, 1, 2);
matplot::plot(ax2, x, y2);
matplot::title(ax2, "Subplot 2");

matplot::show();

Output Console output as expected

Press ENTER to continue...

Platform

Environment Details:

Additional context

j0hnnybash commented 1 year ago

This sounds like an issue I have also encountered.

In my case this was an issue with gnuplot multiplots and the "replotonresize" functionality (which is broken for multiplots and only replots one plot [1]). This option has to be disabled per terminal, usually in the terminals UI e.g. for the QT terminal click on the "wrench" icon and ensure "replot on resize" is unchecked (this setting will be remembered so you only have to do this once).

With the unreleased gnuplot 5.5 the CLI option -noreplotonresize works for both the "qt"2 and "x11" terminals, unfortunately as of gnuplot 5.4 this option only affects the "x11" terminal 2, this could option could be set by the gnuplot backend.

[1]: http://www.gnuplot.info/faq/faq.html section 8.5

Zacrain commented 1 year ago

In my case this was an issue with gnuplot multiplots and the "replotonresize" functionality (which is broken for multiplots and only replots one plot [1]). This option has to be disabled per terminal, usually in the terminals UI e.g. for the QT terminal click on the "wrench" icon and ensure "replot on resize" is unchecked (this setting will be remembered so you only have to do this once).

This alleviates the issue on resizing. But that does not help when toggling the grid on / off. In that case one of the subplots still disappears. Also zooming in doesn't seem to work for both subplots.