alandefreitas / matplotplusplus

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

No obvious way to clear the plot #224

Closed yurivict closed 2 years ago

yurivict commented 2 years ago

I need to show multiple plots in the same process.

Adding plots and calling show() again shows plot with all previous drawings combined.

There is no "erase()" or "clear()" or "reset()" function and every testcase in the docs has a main function that exits immediately after the plot.

Could you please add a paragraph to the documentation on how to show consecutive plots in the sane process?

alandefreitas commented 2 years ago

You either need to create multiplots or work with multiple figure objects.

show() and draw() and meant to just show what's in the figure for member functions, or the current figure for the free function. They have nothing to do with clearing the plot.

The usual way to clear the plot in these libraries is to leave quiet mode, and then plot something else.

If you want to edit the objects directly, the axes have a member function to clear their object and a children function to get its children so you can edit their objects. You can also access the figure children and edit, or clear, them. There's no clear function to do that in one step. This could be useful, to maintain symmetry with the axes. It just hasn't been requested. A small PR to improve this is welcome.

About the docs, they need improvements everywhere. There's no single issue for that, but any PR improving the docs here and there are also welcome.

yurivict commented 2 years ago

gca()->children({ }); clears the plot, but this looks like a hack.


A small PR to improve this is welcome.

Sorry, I don't have resources for a PR at this time.