Skip to content

Commit

Permalink
changed color name in cm to a static const char
Browse files Browse the repository at this point in the history
Signed-off-by: soblin <[email protected]>
  • Loading branch information
soblin committed Oct 22, 2022
1 parent b51db01 commit d418287
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gallery/images_contours_and_fields/contourf_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int main() {
auto [fig, ax] = plt.subplots();
auto cs = ax.contourf(Args(Xpy, Ypy, zpy),
Kwargs("locator"_a = ticker::LogLocator().unwrap(),
"cmap"_a = cm::PuBu_r()));
"cmap"_a = cm::PuBu_r));
fig.colorbar(Args(cs));
plt.show();
}
3 changes: 2 additions & 1 deletion gallery/images_contours_and_fields/image_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// https://matplotlib.org/stable/gallery/images_contours_and_fields/image_demo.html

#include <matplotlibcpp17/pyplot.h>
#include <matplotlibcpp17/cm.h>

#include <xtensor/xbuilder.hpp>
#include <xtensor/xview.hpp>
Expand Down Expand Up @@ -43,7 +44,7 @@ int main() {
vmin = *min_element(Z_.begin(), Z_.end());
auto Zpy = py::array(py::cast(std::move(Z2D)));
ax.imshow(Args(Zpy), Kwargs("interpolation"_a = "bilinear",
"cmap"_a = "RdYlGn", "origin"_a = "lower",
"cmap"_a = cm::RdYlGn, "origin"_a = "lower",
"extent"_a = py::make_tuple(-3, 3, -3, 3),
"vmax"_a = vmax, "vmin"_a = vmin));
#if USE_GUI
Expand Down
7 changes: 2 additions & 5 deletions include/matplotlibcpp17/cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ pybind11::object coolwarm() {
return ret;
}

pybind11::object PuBu_r() {
pybind11::object ret =
pybind11::module::import("matplotlib.cm").attr("PuBu_r");
return ret;
}
static const char *PuBu_r = "PuBu_r";
static const char *RdYlGn = "RdYlGn";

} // namespace matplotlibcpp17::cm

Expand Down

0 comments on commit d418287

Please sign in to comment.