Skip to content

Commit d418287

Browse files
committed
changed color name in cm to a static const char
Signed-off-by: soblin <hilo.soblin@gmail.com>
1 parent b51db01 commit d418287

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

gallery/images_contours_and_fields/contourf_log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main() {
5252
auto [fig, ax] = plt.subplots();
5353
auto cs = ax.contourf(Args(Xpy, Ypy, zpy),
5454
Kwargs("locator"_a = ticker::LogLocator().unwrap(),
55-
"cmap"_a = cm::PuBu_r()));
55+
"cmap"_a = cm::PuBu_r));
5656
fig.colorbar(Args(cs));
5757
plt.show();
5858
}

gallery/images_contours_and_fields/image_demo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// https://matplotlib.org/stable/gallery/images_contours_and_fields/image_demo.html
33

44
#include <matplotlibcpp17/pyplot.h>
5+
#include <matplotlibcpp17/cm.h>
56

67
#include <xtensor/xbuilder.hpp>
78
#include <xtensor/xview.hpp>
@@ -43,7 +44,7 @@ int main() {
4344
vmin = *min_element(Z_.begin(), Z_.end());
4445
auto Zpy = py::array(py::cast(std::move(Z2D)));
4546
ax.imshow(Args(Zpy), Kwargs("interpolation"_a = "bilinear",
46-
"cmap"_a = "RdYlGn", "origin"_a = "lower",
47+
"cmap"_a = cm::RdYlGn, "origin"_a = "lower",
4748
"extent"_a = py::make_tuple(-3, 3, -3, 3),
4849
"vmax"_a = vmax, "vmin"_a = vmin));
4950
#if USE_GUI

include/matplotlibcpp17/cm.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ pybind11::object coolwarm() {
1616
return ret;
1717
}
1818

19-
pybind11::object PuBu_r() {
20-
pybind11::object ret =
21-
pybind11::module::import("matplotlib.cm").attr("PuBu_r");
22-
return ret;
23-
}
19+
static const char *PuBu_r = "PuBu_r";
20+
static const char *RdYlGn = "RdYlGn";
2421

2522
} // namespace matplotlibcpp17::cm
2623

0 commit comments

Comments
 (0)