Skip to content
Snippets Groups Projects
Unverified Commit 62ee0d3e authored by Mamoru Sobue's avatar Mamoru Sobue Committed by GitHub
Browse files

Merge pull request #19 from soblin/develop

Develop
parents dc423d44 c2dd7040
No related branches found
No related tags found
No related merge requests found
Showing
with 12 additions and 70 deletions
// example from // example from
// https://matplotlib.org/stable/gallery/shapes_and_collections/patch_collection.html // https://matplotlib.org/stable/gallery/shapes_and_collections/patch_collection.html
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <pybind11/numpy.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <matplotlibcpp17/patches.h> #include <matplotlibcpp17/patches.h>
...@@ -12,8 +8,6 @@ ...@@ -12,8 +8,6 @@
#include <vector> #include <vector>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using namespace matplotlibcpp17::patches; using namespace matplotlibcpp17::patches;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
......
// example from https://note.nkmk.me/python-matplotlib-patches-circle-rectangle // example from https://note.nkmk.me/python-matplotlib-patches-circle-rectangle
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <matplotlibcpp17/patches.h> #include <matplotlibcpp17/patches.h>
#include <algorithm> #include <algorithm>
#include <iostream>
#include <vector> #include <vector>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
using namespace matplotlibcpp17::patches; using namespace matplotlibcpp17::patches;
......
// example from https://matplotlib.org/stable/gallery/statistics/errorbar.html // example from https://matplotlib.org/stable/gallery/statistics/errorbar.html
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <xtensor/xrandom.hpp> #include <xtensor/xrandom.hpp>
#include <random> #include <random>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
......
// example from https://matplotlib.org/stable/gallery/statistics/hist.html // example from https://matplotlib.org/stable/gallery/statistics/hist.html
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <xtensor/xrandom.hpp> #include <xtensor/xrandom.hpp>
#include <random>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
......
// example from // example from
// https://matplotlib.org/stable/gallery/subplots_axes_and_figures/align_labels_demo.html // https://matplotlib.org/stable/gallery/subplots_axes_and_figures/align_labels_demo.html
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <xtensor/xbuilder.hpp> #include <xtensor/xbuilder.hpp>
#include <vector> #include <vector>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using matplotlibcpp17::gridspec::GridSpec; using matplotlibcpp17::gridspec::GridSpec;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
......
// example from // example from
// https://matplotlib.org/stable/gallery/subplots_axes_and_figures/colorbar_placement.html // https://matplotlib.org/stable/gallery/subplots_axes_and_figures/colorbar_placement.html
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <xtensor/xrandom.hpp> #include <xtensor/xrandom.hpp>
#include <vector> #include <vector>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
......
// example from // example from
// https://matplotlib.org/stable/gallery/subplots_axes_and_figures/gridspec_multicolumn.html // https://matplotlib.org/stable/gallery/subplots_axes_and_figures/gridspec_multicolumn.html
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <vector> #include <vector>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using matplotlibcpp17::gridspec::GridSpec; using matplotlibcpp17::gridspec::GridSpec;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
......
// example from // example from
// https://matplotlib.org/stable/gallery/subplots_axes_and_figures/multiple_figs_demo.html // https://matplotlib.org/stable/gallery/subplots_axes_and_figures/multiple_figs_demo.html
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <xtensor/xbuilder.hpp> #include <xtensor/xbuilder.hpp>
...@@ -11,8 +8,6 @@ ...@@ -11,8 +8,6 @@
#include <vector> #include <vector>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
......
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
namespace py = pybind11;
using namespace py::literals;
using namespace std; using namespace std;
using namespace matplotlibcpp17; using namespace matplotlibcpp17;
......
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <vector> #include <vector>
using namespace pybind11::literals;
int main() { int main() {
pybind11::scoped_interpreter guard{}; pybind11::scoped_interpreter guard{};
auto plt = matplotlibcpp17::pyplot::import(); auto plt = matplotlibcpp17::pyplot::import();
......
...@@ -243,9 +243,10 @@ private: ...@@ -243,9 +243,10 @@ private:
LOAD_FUNC_ATTR(plot, self); LOAD_FUNC_ATTR(plot, self);
// NOTE: only when called with projection='3d', `plot_surface`, `plot_wireframe`, `set_zlabel` prop exists. // NOTE: only when called with projection='3d', `plot_surface`, `plot_wireframe`, `set_zlabel` prop exists.
try { try {
plot_surface_attr = self.attr("plot_surface"); LOAD_FUNC_ATTR(plot_surface, self);
plot_wireframe_attr = self.attr("plot_wireframe"); LOAD_FUNC_ATTR(plot_wireframe, self);
set_zlabel_attr = self.attr("set_zlabel"); LOAD_FUNC_ATTR(set_zlabel, self);
LOAD_FUNC_ATTR(set_zlim, self);
INFO_MSG("Loaded Axes3D"); INFO_MSG("Loaded Axes3D");
projection_3d = true; projection_3d = true;
} catch (...) { } catch (...) {
...@@ -264,7 +265,6 @@ private: ...@@ -264,7 +265,6 @@ private:
LOAD_FUNC_ATTR(set_ylabel, self); LOAD_FUNC_ATTR(set_ylabel, self);
LOAD_FUNC_ATTR(set_ylim, self); LOAD_FUNC_ATTR(set_ylim, self);
LOAD_FUNC_ATTR(set_yticks, self); LOAD_FUNC_ATTR(set_yticks, self);
LOAD_FUNC_ATTR(set_zlim, self);
LOAD_FUNC_ATTR(text, self); LOAD_FUNC_ATTR(text, self);
LOAD_FUNC_ATTR(tick_params, self); LOAD_FUNC_ATTR(tick_params, self);
} }
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#include <matplotlibcpp17/figure.h> #include <matplotlibcpp17/figure.h>
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <pybind11/numpy.h>
namespace matplotlibcpp17::pyplot { namespace matplotlibcpp17::pyplot {
...@@ -364,10 +367,15 @@ PyPlot import() { ...@@ -364,10 +367,15 @@ PyPlot import() {
} // namespace matplotlibcpp17::pyplot } // namespace matplotlibcpp17::pyplot
// Args & Kwargs
template <typename... ArgsT> pybind11::tuple Args(ArgsT &&... args) { template <typename... ArgsT> pybind11::tuple Args(ArgsT &&... args) {
return pybind11::make_tuple(std::forward<ArgsT>(args)...); return pybind11::make_tuple(std::forward<ArgsT>(args)...);
} }
using Kwargs = pybind11::dict; using Kwargs = pybind11::dict;
// Export this
namespace py = pybind11;
using namespace py::literals;
#endif /* MATPLOTLIBCPP17_PYPLOT_H */ #endif /* MATPLOTLIBCPP17_PYPLOT_H */
// example from // example from
// https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html // https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
namespace py = pybind11;
using namespace py::literals;
template <typename T> std::vector<T> arange(T start, T end, T h) { template <typename T> std::vector<T> arange(T start, T end, T h) {
int N = static_cast<int>((end - start) / h); int N = static_cast<int>((end - start) / h);
std::vector<T> xs(N); std::vector<T> xs(N);
......
// example from // example from
// https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html // https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html
#include <pybind11/stl.h>
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
namespace py = pybind11;
using namespace py::literals;
template <typename T> std::vector<T> arange(T start, T end, T h) { template <typename T> std::vector<T> arange(T start, T end, T h) {
int N = static_cast<int>((end - start) / h); int N = static_cast<int>((end - start) / h);
std::vector<T> xs(N); std::vector<T> xs(N);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment