Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class interface seems not to add axes #367

Open
2 of 8 tasks
MrMoose opened this issue Aug 31, 2023 · 0 comments
Open
2 of 8 tasks

Class interface seems not to add axes #367

MrMoose opened this issue Aug 31, 2023 · 0 comments

Comments

@MrMoose
Copy link

MrMoose commented Aug 31, 2023

Bug category

  • bug - compilation error
  • bug - compilation warning
  • 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
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant