matplotlibcpp17
gridspec.h
1
5#pragma once
6
7#include <matplotlibcpp17/common.h>
8
9#include <pybind11/pybind11.h>
10
11namespace matplotlibcpp17::gridspec {
12
16struct DECL_STRUCT_ATTR SubplotSpec : public BaseWrapper {
17public:
18 SubplotSpec(const pybind11::object &subplotspec) { self = subplotspec; }
19 SubplotSpec(pybind11::object &&subplotspec) { self = std::move(subplotspec); }
20};
21
25struct DECL_STRUCT_ATTR GridSpec : public BaseWrapper {
26public:
27 GridSpec(int nrow_, int ncol_,
28 const pybind11::dict &kwargs = pybind11::dict()) {
29 nrow = nrow_;
30 ncol = ncol_;
31 gridspec_attr =
32 pybind11::module::import("matplotlib.gridspec").attr("GridSpec");
33 self = gridspec_attr(nrow, ncol, **kwargs);
34 }
35 template <typename Rows, typename Cols>
36 SubplotSpec operator()(const Rows &r, const Cols &c) {
37 pybind11::object obj = self[pybind11::make_tuple(r, c)];
38 return SubplotSpec(std::move(obj));
39 }
40
41private:
42 int nrow, ncol;
43 pybind11::object gridspec_attr;
44};
45
46} // namespace matplotlibcpp17::gridspec
A base class for python wrapper classes.
Definition: common.h:39
A wrapper class for matplotlib.gridspec.GridSpec.
Definition: gridspec.h:25
A wrapper class for matplotlib.gridspec.SubplotSpec.
Definition: gridspec.h:16