matplotplusplus icon indicating copy to clipboard operation
matplotplusplus copied to clipboard

Subplot disappears upon resizing of figure

Open mhered opened this issue 2 years ago • 2 comments

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 using tiledlayout)
  • 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

mhered avatar Jun 01 '23 21:06 mhered

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/

j0hnnybash avatar Jun 17 '23 13:06 j0hnnybash

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.

Zacrain avatar Jul 20 '23 16:07 Zacrain