-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathfigure.h
More file actions
137 lines (116 loc) · 4.4 KB
/
Copy pathfigure.h
File metadata and controls
137 lines (116 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**
* @file figure.h
* @brief corresponding header for matplotlib.figure
**/
#pragma once
#include <matplotlibcpp17/axes.h>
#include <matplotlibcpp17/common.h>
#include <matplotlibcpp17/gridspec.h>
#include <pybind11/pybind11.h>
namespace matplotlibcpp17::figure {
/**
* @brief A wrapper class for matplotlib.figure.Figure
**/
struct DECL_STRUCT_ATTR Figure : public BaseWrapper {
public:
Figure(const pybind11::object &figure) {
self = figure;
load_attrs();
}
Figure(pybind11::object &&figure) {
self = std::move(figure);
load_attrs();
}
// add_axes
axes::Axes add_axes(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// add_gridspec
gridspec::GridSpec
add_gridspec(int nrow, int ncol,
const pybind11::dict &kwargs = pybind11::dict());
// add_subplot
axes::Axes add_subplot(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// align_labels
ObjectWrapper align_labels(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// colorbar
ObjectWrapper colorbar(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// savefig
ObjectWrapper savefig(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// suptitle
ObjectWrapper suptitle(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
// tight_layout
ObjectWrapper tight_layout(const pybind11::tuple &args = pybind11::tuple(),
const pybind11::dict &kwargs = pybind11::dict());
private:
void load_attrs() {
LOAD_FUNC_ATTR(add_axes, self);
LOAD_FUNC_ATTR(add_gridspec, self);
LOAD_FUNC_ATTR(add_subplot, self);
LOAD_FUNC_ATTR(align_labels, self);
LOAD_FUNC_ATTR(colorbar, self);
LOAD_FUNC_ATTR(savefig, self);
LOAD_FUNC_ATTR(suptitle, self);
LOAD_FUNC_ATTR(tight_layout, self);
}
pybind11::object add_axes_attr;
pybind11::object add_gridspec_attr;
pybind11::object add_subplot_attr;
pybind11::object align_labels_attr;
pybind11::object colorbar_attr;
pybind11::object savefig_attr;
pybind11::object suptitle_attr;
pybind11::object tight_layout_attr;
};
// add_axes
inline axes::Axes Figure::add_axes(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object obj = add_axes_attr(*args, **kwargs);
return axes::Axes(obj);
}
// add_gridspec
inline gridspec::GridSpec Figure::add_gridspec(int nrow, int ncol,
const pybind11::dict &kwargs) {
return gridspec::GridSpec(nrow, ncol, kwargs);
}
// add_subplot
inline axes::Axes Figure::add_subplot(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object obj = add_subplot_attr(*args, **kwargs);
return axes::Axes(obj);
}
// align_labels
inline ObjectWrapper Figure::align_labels(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object ret = align_labels_attr(*args, **kwargs);
return ObjectWrapper(std::move(ret));
}
// colorbar
inline ObjectWrapper Figure::colorbar(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object ret = colorbar_attr(*args, **kwargs);
return ObjectWrapper(std::move(ret));
}
// savefig
inline ObjectWrapper Figure::savefig(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object ret = savefig_attr(*args, **kwargs);
return ObjectWrapper(std::move(ret));
}
// suptitle
inline ObjectWrapper Figure::suptitle(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object ret = suptitle_attr(*args, **kwargs);
return ObjectWrapper(std::move(ret));
}
// tight_layout
inline ObjectWrapper Figure::tight_layout(const pybind11::tuple &args,
const pybind11::dict &kwargs) {
pybind11::object ret = tight_layout_attr(*args, **kwargs);
return ObjectWrapper(std::move(ret));
}
} // namespace matplotlibcpp17::figure