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

Plot3 and Plot_Surface window cannot be updated with new data in loops #349

Open
msk2000 opened this issue Jul 6, 2023 · 1 comment
Open

Comments

@msk2000
Copy link

msk2000 commented Jul 6, 2023

You can put the 2d plots in a for loop and it will result in the new data being plotting inside the same open figure window.

However, for 3d plots like plot3 and plot_surface, doing this exact same thing will cause a brand new figure window to spawn. What is even worse is that every window remains fully active and updating all at once!

I'd greatly appreciate if someone helped me overcome this annoying bug which makes all 3d plots unusable for me.

@lanzhan777
Copy link

lanzhan777 commented Jul 23, 2023

You can specify the figure handle of function plot3, which default value is 0:

void plot3(const std::vector<Numeric> &x,
                  const std::vector<Numeric> &y,
                  const std::vector<Numeric> &z,
                  const std::map<std::string, std::string> &keywords =
                      std::map<std::string, std::string>(),
                  const long fig_number=0);

such as:

     map<string, string> set_1, set_2, set_3;
     set_1.insert({"label", "system trajectory"});
     set_2.insert({"label", "control polygon"});
     set_3.insert({"label", "control points"});
     auto fg=plt::figure();//figure handle
     plt::plot3(Cu[0], Cu[1], Cu[2], set_1,fg);
     plt::plot3(Cu[3], Cu[4], Cu[5], set_2, fg);
     plt::scatter(Cu[3], Cu[4], Cu[5], 1, set_3, fg);
     plt::xlabel("x");
     plt::ylabel("y");
     plt::set_zlabel("z");
     plt::legend();
     plt::show();

Then the call of plot3 and scatter will show in one figure.

also can refer to #306 (comment)

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

2 participants