alandefreitas / matplotplusplus

Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
https://alandefreitas.github.io/matplotplusplus/
MIT License
4.34k stars 334 forks source link

multi line plot dose not work as expected #414

Open ziyuanbaby opened 4 months ago

ziyuanbaby commented 4 months ago

Discussed in https://github.com/alandefreitas/matplotplusplus/discussions/412

Originally posted by **ziyuanbaby** July 5, 2024 ``` using namespace matplot; hold(on); for (int i = 0; i < 5; i++) { std::vector x = linspace(0, pi); std::vector y1 = transform(x, [&](auto x) { return cos(x * (i + 1)); }); plot(x, y1, "-o"); } legend(); show(); ``` the above code draw 5 lines. but only the first one is shown on the figure. ![image](https://github.com/alandefreitas/matplotplusplus/assets/35264651/8743f1d6-ba4f-405a-92ba-ea3e48cecae6) however, when i only draw three lines, it works as expected. can anyone tell me where i am doing wrong? ``` using namespace matplot; hold(on); for (int i = 0; i < 3; i++) { std::vector x = linspace(0, pi); std::vector y1 = transform(x, [&](auto x) { return cos(x * (i + 1)); }); plot(x, y1, "-o"); } legend(); show(); ``` ![image](https://github.com/alandefreitas/matplotplusplus/assets/35264651/04f45b54-6bde-4b84-b8db-7eff991f0df8)