matplotplusplus
matplotplusplus copied to clipboard
Subplot disappears upon resizing of figure
Bug category
- [ ] bug - compilation error
- [ ] bug - compilation warning
- [x] bug - runtime error
- [ ] bug - runtime warning
- [ ] bug - logic error
Describe the bug
- I plot a set of two 2D plots using
subplot(similar behaviour occurs also when usingtiledlayout) - it renders ok-ish with some overlap in the text because the starting size of the figure is too small
- however when I resize the figure with the mouse and it redraws the figure, one of the subplots disappears
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
- [x] cross-platform issue - linux
- [ ] cross-platform issue - windows
- [ ] cross-platform issue - macos
Environment Details:
- OS: ubuntu
- OS Version: 20.04
- Compiler: g++
- Compiler version: 9.4.0
Additional context
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 [2]: http://gnuplot.info/docs_5.5/loc21633.html [3]: https://sourceforge.net/p/gnuplot/bugs/2200/
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.