Skip to content

Commit dcb2322

Browse files
alexdewarBenno Evers
authored andcommitted
Return figure number from figure function
1 parent b124207 commit dcb2322

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

matplotlibcpp.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,12 +816,20 @@ void text(Numeric x, Numeric y, const std::string& s = "")
816816
}
817817

818818

819-
inline void figure()
819+
inline long figure()
820820
{
821821
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_figure, detail::_interpreter::get().s_python_empty_tuple);
822822
if(!res) throw std::runtime_error("Call to figure() failed.");
823823

824+
PyObject* num = PyObject_GetAttrString(res, "number");
825+
if (!num) throw std::runtime_error("Could not get number attribute of figure object");
826+
827+
const long figureNumber = PyLong_AsLong(num);
828+
829+
Py_DECREF(num);
824830
Py_DECREF(res);
831+
832+
return figureNumber;
825833
}
826834

827835
inline void figure_size(size_t w, size_t h)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy