diff --git a/gallery/artist_animation/animate_decay.cpp b/gallery/artist_animation/animate_decay.cpp index 85420ad..a857198 100644 --- a/gallery/artist_animation/animate_decay.cpp +++ b/gallery/artist_animation/animate_decay.cpp @@ -1,18 +1,11 @@ // example from // https://matplotlib.org/stable/gallery/animation/animate_decay.html -#include -#include - #include #include #include -#include -#include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; using matplotlibcpp17::animation::ArtistAnimation; diff --git a/gallery/artist_animation/cla_pause.cpp b/gallery/artist_animation/cla_pause.cpp index 29d233e..8251a64 100644 --- a/gallery/artist_animation/cla_pause.cpp +++ b/gallery/artist_animation/cla_pause.cpp @@ -1,14 +1,7 @@ -#include -#include - #include #include -#include -#include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/artist_animation/random_walk.cpp b/gallery/artist_animation/random_walk.cpp index f67ea0b..a3dcac5 100644 --- a/gallery/artist_animation/random_walk.cpp +++ b/gallery/artist_animation/random_walk.cpp @@ -1,8 +1,5 @@ // example from https://matplotlib.org/stable/gallery/animation/random_walk.html -#include -#include - #include #include @@ -12,8 +9,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; using matplotlibcpp17::animation::ArtistAnimation; diff --git a/gallery/images_contours_and_fields/quiver_demo.cpp b/gallery/images_contours_and_fields/quiver_demo.cpp index 9d46343..bea4f82 100644 --- a/gallery/images_contours_and_fields/quiver_demo.cpp +++ b/gallery/images_contours_and_fields/quiver_demo.cpp @@ -1,9 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/images_contours_and_fields/quiver_demo.html -#include -#include - #include #include @@ -13,8 +10,6 @@ #include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/lines_bars_and_markers/bar_label_demo.cpp b/gallery/lines_bars_and_markers/bar_label_demo.cpp index 95b0360..60a213b 100644 --- a/gallery/lines_bars_and_markers/bar_label_demo.cpp +++ b/gallery/lines_bars_and_markers/bar_label_demo.cpp @@ -1,21 +1,13 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/bar_label_demo.html -#include -#include - #include #include #include #include -#include - -namespace py = pybind11; -using namespace py::literals; using namespace std; - using namespace matplotlibcpp17; int main1() { diff --git a/gallery/lines_bars_and_markers/errorbar_limits_simple.cpp b/gallery/lines_bars_and_markers/errorbar_limits_simple.cpp index 963135f..10fa71e 100644 --- a/gallery/lines_bars_and_markers/errorbar_limits_simple.cpp +++ b/gallery/lines_bars_and_markers/errorbar_limits_simple.cpp @@ -1,9 +1,6 @@ // example // https://matplotlib.org/stable/gallery/lines_bars_and_markers/errorbar_limits_simple.html -#include -#include - #include #include @@ -11,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/lines_bars_and_markers/errorbar_subsample.cpp b/gallery/lines_bars_and_markers/errorbar_subsample.cpp index 4b54b1f..f9a08d3 100644 --- a/gallery/lines_bars_and_markers/errorbar_subsample.cpp +++ b/gallery/lines_bars_and_markers/errorbar_subsample.cpp @@ -1,9 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/errorbar_subsample.html -#include -#include - #include #include @@ -11,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/lines_bars_and_markers/fill.cpp b/gallery/lines_bars_and_markers/fill.cpp index 6bc6bdb..0e763c8 100644 --- a/gallery/lines_bars_and_markers/fill.cpp +++ b/gallery/lines_bars_and_markers/fill.cpp @@ -1,17 +1,12 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/fill.html -#include -#include - #include #include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/lines_bars_and_markers/fill_between_demo.cpp b/gallery/lines_bars_and_markers/fill_between_demo.cpp index baf6654..1e4e0b3 100644 --- a/gallery/lines_bars_and_markers/fill_between_demo.cpp +++ b/gallery/lines_bars_and_markers/fill_between_demo.cpp @@ -1,9 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/fill_between_demo.html -#include -#include - #include #include @@ -11,12 +8,8 @@ #include #include -#include -#include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/lines_bars_and_markers/fill_betweenx_demo.cpp b/gallery/lines_bars_and_markers/fill_betweenx_demo.cpp index d90fe4b..eefa7a3 100644 --- a/gallery/lines_bars_and_markers/fill_betweenx_demo.cpp +++ b/gallery/lines_bars_and_markers/fill_betweenx_demo.cpp @@ -1,9 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/fill_betweenx_demo.html -#include -#include - #include #include @@ -11,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/lines_bars_and_markers/scatter_hist.cpp b/gallery/lines_bars_and_markers/scatter_hist.cpp index 706b55f..5118a30 100644 --- a/gallery/lines_bars_and_markers/scatter_hist.cpp +++ b/gallery/lines_bars_and_markers/scatter_hist.cpp @@ -1,9 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/scatter_hist.html -#include -#include - #include #include @@ -12,8 +9,6 @@ #include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/lines_bars_and_markers/scatter_symbol.cpp b/gallery/lines_bars_and_markers/scatter_symbol.cpp index 56db266..8c82d81 100644 --- a/gallery/lines_bars_and_markers/scatter_symbol.cpp +++ b/gallery/lines_bars_and_markers/scatter_symbol.cpp @@ -1,18 +1,11 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/scatter_symbol.html -#include -#include - #include -#include #include #include -namespace py = pybind11; -using namespace py::literals; - template std::vector arange(T start, T end, T h) { int N = static_cast((end - start) / h); std::vector xs(N); diff --git a/gallery/lines_bars_and_markers/scatter_with_legend.cpp b/gallery/lines_bars_and_markers/scatter_with_legend.cpp index 50025a3..57d97d5 100644 --- a/gallery/lines_bars_and_markers/scatter_with_legend.cpp +++ b/gallery/lines_bars_and_markers/scatter_with_legend.cpp @@ -1,9 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/scatter_with_legend.html -#include -#include - #include #include @@ -11,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/lines_bars_and_markers/simple_plot.cpp b/gallery/lines_bars_and_markers/simple_plot.cpp index d0e5843..ed7b234 100644 --- a/gallery/lines_bars_and_markers/simple_plot.cpp +++ b/gallery/lines_bars_and_markers/simple_plot.cpp @@ -1,9 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html -#include -#include - #include #include @@ -11,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/mplot3d/contour3d.cpp b/gallery/mplot3d/contour3d.cpp index bb02ae1..85fe0d4 100644 --- a/gallery/mplot3d/contour3d.cpp +++ b/gallery/mplot3d/contour3d.cpp @@ -1,19 +1,12 @@ // example https://matplotlib.org/stable/gallery/mplot3d/contour3d.html -#include -#include - #include #include #include -#include -#include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/mplot3d/errorbar3d.cpp b/gallery/mplot3d/errorbar3d.cpp index b5bf7c3..283a0bb 100644 --- a/gallery/mplot3d/errorbar3d.cpp +++ b/gallery/mplot3d/errorbar3d.cpp @@ -1,8 +1,5 @@ // example from https://matplotlib.org/stable/gallery/mplot3d/errorbar3d.html -#include -#include - #include #include @@ -11,8 +8,6 @@ #include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/mplot3d/lines3d.cpp b/gallery/mplot3d/lines3d.cpp index 0d91953..186502f 100644 --- a/gallery/mplot3d/lines3d.cpp +++ b/gallery/mplot3d/lines3d.cpp @@ -1,8 +1,5 @@ // example from https://matplotlib.org/stable/gallery/mplot3d/lines3d.html -#include -#include - #include #include @@ -10,8 +7,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/mplot3d/lorenz_attractor.cpp b/gallery/mplot3d/lorenz_attractor.cpp index e2a4669..562b6ae 100644 --- a/gallery/mplot3d/lorenz_attractor.cpp +++ b/gallery/mplot3d/lorenz_attractor.cpp @@ -1,15 +1,10 @@ // example from // https://matplotlib.org/stable/gallery/mplot3d/lorenz_attractor.html -#include -#include #include -#include + #include -#include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/mplot3d/subplot3d.cpp b/gallery/mplot3d/subplot3d.cpp index 93d6d76..8f9f639 100644 --- a/gallery/mplot3d/subplot3d.cpp +++ b/gallery/mplot3d/subplot3d.cpp @@ -1,9 +1,5 @@ // example https://matplotlib.org/stable/gallery/mplot3d/subplot3d.html -#include -#include -#include - #include #include @@ -12,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/mplot3d/surface3d.cpp b/gallery/mplot3d/surface3d.cpp index 1454f2e..2553bd9 100644 --- a/gallery/mplot3d/surface3d.cpp +++ b/gallery/mplot3d/surface3d.cpp @@ -1,9 +1,5 @@ // example from https://matplotlib.org/stable/gallery/mplot3d/surface3d.html -#include -#include -#include - #include #include @@ -12,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/shapes_and_collections/patch_collection.cpp b/gallery/shapes_and_collections/patch_collection.cpp index f516360..ea5be4e 100644 --- a/gallery/shapes_and_collections/patch_collection.cpp +++ b/gallery/shapes_and_collections/patch_collection.cpp @@ -1,10 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/shapes_and_collections/patch_collection.html -#include -#include -#include - #include #include @@ -12,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17::patches; using namespace matplotlibcpp17; diff --git a/gallery/shapes_and_collections/patches_circle_rectangle.cpp b/gallery/shapes_and_collections/patches_circle_rectangle.cpp index bd267da..d3066da 100644 --- a/gallery/shapes_and_collections/patches_circle_rectangle.cpp +++ b/gallery/shapes_and_collections/patches_circle_rectangle.cpp @@ -1,17 +1,11 @@ // example from https://note.nkmk.me/python-matplotlib-patches-circle-rectangle -#include -#include - #include #include #include -#include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; using namespace matplotlibcpp17::patches; diff --git a/gallery/statistics/errorbar.cpp b/gallery/statistics/errorbar.cpp index 28f74f8..5357a8f 100644 --- a/gallery/statistics/errorbar.cpp +++ b/gallery/statistics/errorbar.cpp @@ -1,16 +1,11 @@ // example from https://matplotlib.org/stable/gallery/statistics/errorbar.html -#include -#include - #include #include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/statistics/hist.cpp b/gallery/statistics/hist.cpp index 339bdb9..70c790f 100644 --- a/gallery/statistics/hist.cpp +++ b/gallery/statistics/hist.cpp @@ -1,16 +1,9 @@ // example from https://matplotlib.org/stable/gallery/statistics/hist.html -#include -#include - #include #include -#include - -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/subplots_axes_and_figures/align_labels_demo.cpp b/gallery/subplots_axes_and_figures/align_labels_demo.cpp index aa3d9e5..ac14f54 100644 --- a/gallery/subplots_axes_and_figures/align_labels_demo.cpp +++ b/gallery/subplots_axes_and_figures/align_labels_demo.cpp @@ -1,17 +1,12 @@ // example from // https://matplotlib.org/stable/gallery/subplots_axes_and_figures/align_labels_demo.html -#include -#include - #include #include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using matplotlibcpp17::gridspec::GridSpec; using namespace matplotlibcpp17; diff --git a/gallery/subplots_axes_and_figures/colorbar_placement.cpp b/gallery/subplots_axes_and_figures/colorbar_placement.cpp index 1d14344..9f1e341 100644 --- a/gallery/subplots_axes_and_figures/colorbar_placement.cpp +++ b/gallery/subplots_axes_and_figures/colorbar_placement.cpp @@ -1,17 +1,12 @@ // example from // https://matplotlib.org/stable/gallery/subplots_axes_and_figures/colorbar_placement.html -#include -#include - #include #include #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp b/gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp index 3b99198..afd2e7e 100644 --- a/gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp +++ b/gallery/subplots_axes_and_figures/gridspec_multicolumn.cpp @@ -1,18 +1,11 @@ // example from // https://matplotlib.org/stable/gallery/subplots_axes_and_figures/gridspec_multicolumn.html -#include -#include - #include #include -namespace py = pybind11; -using namespace py::literals; - using namespace std; - using matplotlibcpp17::gridspec::GridSpec; using namespace matplotlibcpp17; diff --git a/gallery/subplots_axes_and_figures/multiple_figs_demo.cpp b/gallery/subplots_axes_and_figures/multiple_figs_demo.cpp index 5daa0cc..b40a8c0 100644 --- a/gallery/subplots_axes_and_figures/multiple_figs_demo.cpp +++ b/gallery/subplots_axes_and_figures/multiple_figs_demo.cpp @@ -1,9 +1,6 @@ // example from // https://matplotlib.org/stable/gallery/subplots_axes_and_figures/multiple_figs_demo.html -#include -#include - #include #include @@ -11,8 +8,6 @@ #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/gallery/subplots_axes_and_figures/subplots.cpp b/gallery/subplots_axes_and_figures/subplots.cpp index 074e811..635062d 100644 --- a/gallery/subplots_axes_and_figures/subplots.cpp +++ b/gallery/subplots_axes_and_figures/subplots.cpp @@ -1,10 +1,5 @@ -#include -#include - #include -namespace py = pybind11; -using namespace py::literals; using namespace std; using namespace matplotlibcpp17; diff --git a/hello_world/hello_world.cpp b/hello_world/hello_world.cpp index 8ae697b..93a4dc7 100644 --- a/hello_world/hello_world.cpp +++ b/hello_world/hello_world.cpp @@ -1,12 +1,7 @@ -#include -#include - #include #include -using namespace pybind11::literals; - int main() { pybind11::scoped_interpreter guard{}; auto plt = matplotlibcpp17::pyplot::import(); diff --git a/include/matplotlibcpp17/axes.h b/include/matplotlibcpp17/axes.h index be8fe53..187dca4 100644 --- a/include/matplotlibcpp17/axes.h +++ b/include/matplotlibcpp17/axes.h @@ -243,9 +243,10 @@ struct DECL_STRUCT_ATTR Axes : public BaseWrapper { LOAD_FUNC_ATTR(plot, self); // NOTE: only when called with projection='3d', `plot_surface`, `plot_wireframe`, `set_zlabel` prop exists. try { - plot_surface_attr = self.attr("plot_surface"); - plot_wireframe_attr = self.attr("plot_wireframe"); - set_zlabel_attr = self.attr("set_zlabel"); + LOAD_FUNC_ATTR(plot_surface, self); + LOAD_FUNC_ATTR(plot_wireframe, self); + LOAD_FUNC_ATTR(set_zlabel, self); + LOAD_FUNC_ATTR(set_zlim, self); INFO_MSG("Loaded Axes3D"); projection_3d = true; } catch (...) { @@ -264,7 +265,6 @@ struct DECL_STRUCT_ATTR Axes : public BaseWrapper { LOAD_FUNC_ATTR(set_ylabel, self); LOAD_FUNC_ATTR(set_ylim, self); LOAD_FUNC_ATTR(set_yticks, self); - LOAD_FUNC_ATTR(set_zlim, self); LOAD_FUNC_ATTR(text, self); LOAD_FUNC_ATTR(tick_params, self); } diff --git a/include/matplotlibcpp17/pyplot.h b/include/matplotlibcpp17/pyplot.h index 59a6aa2..1fb7d03 100644 --- a/include/matplotlibcpp17/pyplot.h +++ b/include/matplotlibcpp17/pyplot.h @@ -13,6 +13,9 @@ #include #include +#include +#include +#include namespace matplotlibcpp17::pyplot { @@ -364,10 +367,15 @@ PyPlot import() { } // namespace matplotlibcpp17::pyplot +// Args & Kwargs template pybind11::tuple Args(ArgsT &&... args) { return pybind11::make_tuple(std::forward(args)...); } using Kwargs = pybind11::dict; +// Export this +namespace py = pybind11; +using namespace py::literals; + #endif /* MATPLOTLIBCPP17_PYPLOT_H */ diff --git a/tests/test_shared_lib/test_lib.cpp b/tests/test_shared_lib/test_lib.cpp index 3eae2d9..ab6f4fb 100644 --- a/tests/test_shared_lib/test_lib.cpp +++ b/tests/test_shared_lib/test_lib.cpp @@ -1,16 +1,11 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html -#include - #include #include #include -namespace py = pybind11; -using namespace py::literals; - template std::vector arange(T start, T end, T h) { int N = static_cast((end - start) / h); std::vector xs(N); diff --git a/tests/test_static_lib/test_lib.cpp b/tests/test_static_lib/test_lib.cpp index 3eae2d9..ab6f4fb 100644 --- a/tests/test_static_lib/test_lib.cpp +++ b/tests/test_static_lib/test_lib.cpp @@ -1,16 +1,11 @@ // example from // https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html -#include - #include #include #include -namespace py = pybind11; -using namespace py::literals; - template std::vector arange(T start, T end, T h) { int N = static_cast((end - start) / h); std::vector xs(N);