Skip to content

Commit 8cc5165

Browse files
committed
fixed feature/error-bar on matplotlib==3.5.1
1 parent 92c6899 commit 8cc5165

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if(NOT MATPLOTLIB_VERSION_CHECKING MATCHES 0)
2525
message(FATAL_ERROR
2626
"Could not check matplotlib.__version__")
2727
endif()
28-
message("Detected matplotlib version is ${MATPLOTLIB_VERSION}")
28+
message(STATUS "Detected matplotlib version is ${MATPLOTLIB_VERSION}")
2929
if(${MATPLOTLIB_VERSION} VERSION_LESS 3.4)
3030
message(WARNING "Detected matplotlib version is < 3.4.0")
3131
set(MATPLOTLIB_MINOR_VER_GTE_4 0)

gallery/mplot3d/errorbar3d.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ int main() {
2828
y(y_.begin(), y_.end()), z(z_.begin(), z_.end());
2929

3030
const int estep = 15;
31-
vector<int> i, zuplims, zlolims;
32-
std::iota(i.begin(), i.end(), 0);
31+
vector<int> i(t_.shape()[0]), zuplims, zlolims;
32+
std::iota(i.begin(), i.end(), t_.shape()[0]);
3333
std::transform(i.begin(), i.end(), std::back_inserter(zuplims), [](int i) {
3434
return (i % 15 == 0) and ((i / estep) % 3 == 0);
3535
});

include/matplotlibcpp17/axes.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,18 @@ pybind11::object Axes::contour(const pybind11::tuple &args,
365365
// errorbar
366366
pybind11::object Axes::errorbar(const pybind11::tuple &args,
367367
const pybind11::dict &kwargs) {
368-
if (not projection_3d) {
368+
if (projection_3d) {
369+
#if MATPLOTLIB_MINOR_VER_GTE_4
369370
pybind11::object obj = errorbar_attr(*args, **kwargs);
370371
return obj;
371-
} else {
372+
#else
372373
ERROR_MSG("Call to errorbar with projection='3d' is invalid because "
373374
"matplotlib version is < 3.4.0");
374375
std::exit(0);
376+
#endif
377+
} else {
378+
pybind11::object obj = errorbar_attr(*args, **kwargs);
379+
return obj;
375380
}
376381
}
377382

0 commit comments

Comments
 (0)