diff --git a/visualization/autoware_pyplot/CMakeLists.txt b/common/autoware_pyplot/CMakeLists.txt similarity index 100% rename from visualization/autoware_pyplot/CMakeLists.txt rename to common/autoware_pyplot/CMakeLists.txt diff --git a/common/autoware_pyplot/README.md b/common/autoware_pyplot/README.md new file mode 100644 index 0000000000000..ded3387fefd99 --- /dev/null +++ b/common/autoware_pyplot/README.md @@ -0,0 +1,43 @@ +# autoware_pyplot + +This package provides C++ interface for the notable `matplotlib` using `pybind11` backend for + +- creating scientific plots and images illustrating the function inputs/outputs +- debugging the output and internal data of a function before unit testing in a more lightweight manner than planning_simulator + +## usage + +In your main function, setup the python context and import `matplotlib` + +```cpp +#include +#include + +// in main... + py::scoped_interpreter guard{}; + auto plt = autoware::pyplot::import(); +``` + +Then you can use major functionalities of `matplotlib` almost in the same way as native python code. + +```cpp +{ + plt.plot(Args(std::vector({1, 3, 2, 4})), Kwargs("color"_a = "blue", "linewidth"_a = 1.0)); + plt.xlabel(Args("x-title")); + plt.ylabel(Args("y-title")); + plt.title(Args("title")); + plt.xlim(Args(0, 5)); + plt.ylim(Args(0, 5)); + plt.grid(Args(true)); + plt.savefig(Args("test_single_plot.png")); +} + +{ + auto [fig, axes] = plt.subplots(1, 2); + auto & ax1 = axes[0]; + auto & ax2 = axes[1]; + + ax1.set_aspect(Args("equal")); + ax2.set_aspect(Args("equal")); +} +``` diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/axes.hpp b/common/autoware_pyplot/include/autoware/pyplot/axes.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/axes.hpp rename to common/autoware_pyplot/include/autoware/pyplot/axes.hpp diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/common.hpp b/common/autoware_pyplot/include/autoware/pyplot/common.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/common.hpp rename to common/autoware_pyplot/include/autoware/pyplot/common.hpp diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/figure.hpp b/common/autoware_pyplot/include/autoware/pyplot/figure.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/figure.hpp rename to common/autoware_pyplot/include/autoware/pyplot/figure.hpp diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/legend.hpp b/common/autoware_pyplot/include/autoware/pyplot/legend.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/legend.hpp rename to common/autoware_pyplot/include/autoware/pyplot/legend.hpp diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/loader.hpp b/common/autoware_pyplot/include/autoware/pyplot/loader.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/loader.hpp rename to common/autoware_pyplot/include/autoware/pyplot/loader.hpp diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/patches.hpp b/common/autoware_pyplot/include/autoware/pyplot/patches.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/patches.hpp rename to common/autoware_pyplot/include/autoware/pyplot/patches.hpp diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/pyplot.hpp b/common/autoware_pyplot/include/autoware/pyplot/pyplot.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/pyplot.hpp rename to common/autoware_pyplot/include/autoware/pyplot/pyplot.hpp diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/quiver.hpp b/common/autoware_pyplot/include/autoware/pyplot/quiver.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/quiver.hpp rename to common/autoware_pyplot/include/autoware/pyplot/quiver.hpp diff --git a/visualization/autoware_pyplot/include/autoware/pyplot/text.hpp b/common/autoware_pyplot/include/autoware/pyplot/text.hpp similarity index 100% rename from visualization/autoware_pyplot/include/autoware/pyplot/text.hpp rename to common/autoware_pyplot/include/autoware/pyplot/text.hpp diff --git a/visualization/autoware_pyplot/package.xml b/common/autoware_pyplot/package.xml similarity index 100% rename from visualization/autoware_pyplot/package.xml rename to common/autoware_pyplot/package.xml diff --git a/visualization/autoware_pyplot/src/axes.cpp b/common/autoware_pyplot/src/axes.cpp similarity index 100% rename from visualization/autoware_pyplot/src/axes.cpp rename to common/autoware_pyplot/src/axes.cpp diff --git a/visualization/autoware_pyplot/src/common.cpp b/common/autoware_pyplot/src/common.cpp similarity index 100% rename from visualization/autoware_pyplot/src/common.cpp rename to common/autoware_pyplot/src/common.cpp diff --git a/visualization/autoware_pyplot/src/figure.cpp b/common/autoware_pyplot/src/figure.cpp similarity index 100% rename from visualization/autoware_pyplot/src/figure.cpp rename to common/autoware_pyplot/src/figure.cpp diff --git a/visualization/autoware_pyplot/src/legend.cpp b/common/autoware_pyplot/src/legend.cpp similarity index 100% rename from visualization/autoware_pyplot/src/legend.cpp rename to common/autoware_pyplot/src/legend.cpp diff --git a/visualization/autoware_pyplot/src/patches.cpp b/common/autoware_pyplot/src/patches.cpp similarity index 100% rename from visualization/autoware_pyplot/src/patches.cpp rename to common/autoware_pyplot/src/patches.cpp diff --git a/visualization/autoware_pyplot/src/pyplot.cpp b/common/autoware_pyplot/src/pyplot.cpp similarity index 100% rename from visualization/autoware_pyplot/src/pyplot.cpp rename to common/autoware_pyplot/src/pyplot.cpp diff --git a/visualization/autoware_pyplot/src/quiver.cpp b/common/autoware_pyplot/src/quiver.cpp similarity index 100% rename from visualization/autoware_pyplot/src/quiver.cpp rename to common/autoware_pyplot/src/quiver.cpp diff --git a/visualization/autoware_pyplot/src/text.cpp b/common/autoware_pyplot/src/text.cpp similarity index 100% rename from visualization/autoware_pyplot/src/text.cpp rename to common/autoware_pyplot/src/text.cpp diff --git a/visualization/autoware_pyplot/test/test_pyplot.cpp b/common/autoware_pyplot/test/test_pyplot.cpp similarity index 100% rename from visualization/autoware_pyplot/test/test_pyplot.cpp rename to common/autoware_pyplot/test/test_pyplot.cpp