Skip to content

Commit 831f1ec

Browse files
committed
added cm for mplot3d/subplot3d.cpp
1 parent 481af1a commit 831f1ec

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

gallery/mplot3d/subplot3d.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <pybind11/numpy.h>
66

77
#include <matplotlibcpp17/pyplot.h>
8+
#include <matplotlibcpp17/cm.h>
89

910
#include <xtensor/xbuilder.hpp>
1011
#include <xtensor/xmath.hpp>
@@ -79,8 +80,9 @@ int main() {
7980
auto Y_ = py::array(py::cast(std::move(Y)));
8081
auto Z_ = py::array(py::cast(std::move(Z)));
8182
auto surf = ax.plot_surface(
82-
Args(X_, Y_, Z_), Kwargs("rstride"_a = 1, "cstride"_a = 1,
83-
"linewidth"_a = 0, "antialiased"_a = false));
83+
Args(X_, Y_, Z_),
84+
Kwargs("rstride"_a = 1, "cstride"_a = 1, "linewidth"_a = 0,
85+
"antialiased"_a = false, "cmap"_a = cm::coolwarm()));
8486
ax.set_zlim(Args(-1.01, 1.01));
8587
fig.colorbar(Args(surf), Kwargs("shrink"_a = 0.5, "aspect"_a = 10));
8688
}

include/matplotlibcpp17/cm.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @file cm.h
3+
* @brief corresponding header for matplotlib.animation
4+
**/
5+
6+
#ifndef MATPLOTLIBCPP17_CM_H
7+
#define MATPLOTLIBCPP17_CM_H
8+
9+
#include <pybind11/pybind11.h>
10+
11+
#include <matplotlibcpp17/common.h>
12+
13+
namespace matplotlibcpp17::cm {
14+
15+
pybind11::object coolwarm() {
16+
pybind11::object ret =
17+
pybind11::module::import("matplotlib.cm").attr("coolwarm");
18+
return ret;
19+
}
20+
21+
} // namespace matplotlibcpp17::cm
22+
23+
#endif /* MATPLOTLIBCPP17_CM_H */

0 commit comments

Comments
 (0)