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

how to use colorbar? #307

Open gaopeng-nreal opened 2 years ago

gaopeng-nreal commented 2 years ago

Thanks a lot for your work, I'm new to c++ and ran into this problem. When I draw a heat map, using colorbar, I get an error like this: what(): Must call colorbar with PyObject* returned from an image, contour, surface, etc.

this is my code: matplotlibcpp::imshow((float*)a,20,27,1); matplotlibcpp::colorbar(); matplotlibcpp::show();

gaopeng-nreal commented 2 years ago

solved PyObject* mat; matplotlibcpp::imshow((float*)a,20,27,1,{},&mat); matplotlibcpp::colorbar(mat);