-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(autoware_pyplot): add missing readme and move the package to com…
…mon (#9546)
- Loading branch information
Showing
21 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <autoware/pyplot/pyplot.hpp> | ||
#include <pybind11/embed.h> | ||
|
||
// 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<int>({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")); | ||
} | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.