lava / matplotlib-cpp

Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib
MIT License
4.28k stars 1.12k forks source link

(Solved) MatplotlibDeprecationWarning: Passing non-integers as three-element position specification is deprecated since 3.3 and will be removed two minor releases later. #285

Open GordonEldest opened 2 years ago

GordonEldest commented 2 years ago

MSVC 2019 vanillia

Some argument are transmitted as "float" when they should be "long", This generate warning from python plot lib (as is mentioned in this issue subject)

Example "subplot"

inline void subplot(long nrows, long ncols, long plot_number)
{
    detail::_interpreter::get();

    // construct positional args
    PyObject* args = PyTuple_New(3);
    PyTuple_SetItem(args, 0, PyFloat_FromDouble(nrows));
    PyTuple_SetItem(args, 1, PyFloat_FromDouble(ncols));
    PyTuple_SetItem(args, 2, PyFloat_FromDouble(plot_number));
...

Work fine (and without warning from python plot) just doing replacement on the 3 above PyFloat_FromDoublewith PyLong_FromLong

This is alike what is already done in "subplot2grid". I suggest to consider this for "subplot" in main trunk. thanks