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

3D line plot not showing any data #350

Open
manumerous opened this issue Jul 15, 2023 · 0 comments
Open

3D line plot not showing any data #350

manumerous opened this issue Jul 15, 2023 · 0 comments

Comments

@manumerous
Copy link

manumerous commented Jul 15, 2023

I am trying to use matplotlib-cpp to plot a 3D trajectory but can not get the 3D plot to show any data.

When I plot the 3 axis (x,y,z) separately in a normal 2D plot I can verify that the all data (contained in a std::vector) is correct and bounded:

lorenz_attractor_figure1

However, when I try to plot the data in the 3D line plot, as explained by the provided example, I just get an empty plot. The limits of each axis is correct given the data in plot 1. But the second plot just does not show any data.

lorenz_attractor_figure2

Since I followed the provided example as closely as possible I am not sure how I could fix this. Is this a bug or am I missing something?

The code used to generate the plots is as follows:

  plt::plot(trajectory.getTimeStamps(), trajectory.getSingleStateValues(0), {{"label", "x"}});
  plt::plot(trajectory.getTimeStamps(), trajectory.getSingleStateValues(1), {{"label", "y"}});
  plt::plot(trajectory.getTimeStamps(), trajectory.getSingleStateValues(2), {{"label", "z"}});

  plt::title("Simulated Lorenz Attractor System");
  plt::xlabel("Time [s]");
  plt::ylabel("Position [m]");
  plt::legend();

  plt::show();

  std::map<std::string, std::string> keywords;
  keywords.insert(std::pair<std::string, std::string>("label", "system trajectory"));

  plt::plot3(trajectory.getSingleStateValues(0), trajectory.getSingleStateValues(1), trajectory.getSingleStateValues(2), keywords);
  plt::xlabel("x");
  plt::ylabel("y");
  plt::set_zlabel("z");  // set_zlabel rather than just zlabel, in accordance with the Axes3D method
  plt::legend();
  plt::show();

The full code I used to generate the plots can be found in lorenzSystem.hpp . I am running the code on a Linux Mint 21system using X-Cinnamon Desktop in case that is relevant.

Any help is apprechiated!

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