Class interface seems not to add axes
Bug category
- [ ] bug - compilation error
- [ ] bug - compilation warning
- [x] bug - runtime error
- [ ] bug - runtime warning
- [ ] bug - logic error
Describe the bug
I was attempting to plot two scatter plots in one figure. I am trying to use the "class interface" which doesn't rely on global data in order to be more in-line with the rest of the code and potentially thread in the future.
According to how I understand some examples, this should work:
namespace plt = matplot;
plt::figure_handle figure = plt::figure();
plt::title("Points");
figure->size(1920, 1080);
plt::axes_handle axes_red = figure->add_axes();
plt::line_handle lh1 = axes_red->scatter(x, y, 10);
lh1->marker_face_color(plt::string_to_color("red"));
plt::axes_handle axes_blue = figure->add_axes();
plt::line_handle lh2 = axes_blue->scatter(h, y, 10);
lh2->marker_face(true);
lh2->marker_face_color(plt::string_to_color("blue"));
figure->save(...);
However, if I do it like this, the second axes (plot) will always replace the first and only one plot is drawn. If I insert this (which as I understand is meant to be for global data interface):
...
plt::axes_handle axes_red = figure->add_axes();
plt::line_handle lh1 = axes_red->scatter(x, y, 10);
lh1->marker_face_color(plt::string_to_color("red"));
plt::hold(true);
plt::axes_handle axes_blue = figure->add_axes();
plt::line_handle lh2 = axes_blue->scatter(h, y, 10);
...
It works. Am I misusing this? Because I was under the impression hold() is only needed for global data interface and add_axes() is pretty clear in it's meaning to add an axes, right?
Steps to Reproduce
Try above code sample.
Output
One scatter plot without hold(), two scatter plots with hold().
Platform
- [ ] cross-platform issue - linux
- [x] cross-platform issue - windows
- [ ] cross-platform issue - macos
Environment Details:
- OS: Win 10
- OS Version:
- Compiler: MSVC143
- Compiler version:
Additional context
Latest gnuplot installed, matplot++ built from sources with JPEG dependency but without anything else.