Open cdalas2 opened 4 years ago
Same on mac, I am on Intellij IDEA. Did you solve it?
Unfortunately not. I ended up just transferring my data to MATLAB and plotting there. Hopefully once I chip away at some of my current workload, I'll come back and try to figure it out. If you end up fixing the issue before then, I hope you'll come back and post it here!
Best, Carlos Alas
Oh I finally find out the reason! In my case, I use the native python2 in mac. But it has matplotlib version 1.x.x. Of course it is too old.
However I did not succeed in updating the matplotlib in the system python2.
Fantastic! Sounds like that could have been my issue as well. On my mac I do have python 2 running. I'm not sure what version of matplotlib I had but it must have been an older version. I'll give it a try with python3 and the newest version of matplotlib soon and report back to confirm their compatibility with matplotlib-cpp.
I meet the same problem in my Mac with sublime when I do the make in my terminal. Could author provide a solution for applying the python3 if it works?
Same problem here!
Matplotlibcpp works with the old package mpl_toolkit module which was installed separately from matplotlib. Now mpl_toolkit is bundled with matplotlib (I think as of version 2 and up). The 3D plotting features of matplotlibcpp are thus deprecated.
I have not come up with a clever work around.
Here is the workaround:
In python, the way we would make 3d charts using mpl_toolkit would work like this.
fig = plt.figure(); ax = fig.gca(projection = '3d')
Nowadays in matplotlib you just do something like this.
fig = plt.figure(); ax = fig.add_subplot(projection = '3d')
In matplotlibcpp.h we just need to change the proper function calls that create the axis object. My use case is updating the scatter plot for 3D around line 1140:
Original:
PyObject *axis = PyObject_Call( gca, detail::_interpreter::get().s_python_empty_tuple, gca_kwargs);
Fixed:
PyObject *axis = PyObject_Call( PyObject_GetAttrString(fig, "add_subplot"), detail::_interpreter::get().s_python_empty_tuple, gca_kwargs);
Hope this helps :)
Worked for me.
I ran all the examples provided and they all worked except for the surface plot example. I run my code on a Mac using Xcode. The error occurs when I use plt::plot_surface(x,y,z) in the example. I plan on using Matplotlib-cpp to do surface plots and so its crucial that I get this to work. Please help!