Hello,
i encountered a problem when trying to set axes as logarithmic in a 3D
plot using plot_surface().
I do not know if it is a known bug or if it is a workaround ...?
the failing code is :
#!/usr/bin/python
import os
import sys
from pylab import *
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d import axes3d
import numpy as np
# parameters we bach on
X = np.arange(0.1, 20, 0.5)
Y = np.arange(0.1, 20, 0.5)
X, Y = np.meshgrid(X, Y)
R = np.sqrt((X-10)**2 + (Y-10)**2)
Z = np.sin(R)
fig = figure(num=None, figsize=(6, 6), dpi=80, facecolor='#F2F2F2',
edgecolor='k')
ax = subplot(111,projection='3d')
# the two following make the plot fail
#ax.set_yscale('log')
ax.set_xscale('log')
ax.plot_surface(X,Y,Z, rstride=1, cstride=1, cmap=cm.jet, linewidths=.5)
show()
and the complete output is :
Traceback (most recent call last):
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 395, in expose_event
self._render_figure(self._pixmap, w, h)
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 75, in _render_figure
FigureCanvasAgg.draw(self)
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 401, in draw
self.figure.draw(self.renderer)
File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py",
line 884, in draw
func(*args)
File
"/usr/local/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py",
line 210, in draw
ax.draw(renderer)
File
"/usr/local/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axis3d.py",
line 393, in draw
tick.draw(renderer)
File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axis.py", line
234, in draw
self.label1.draw(renderer)
File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/text.py", line
591, in draw
ismath=ismath)
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 142, in draw_text
return self.draw_mathtext(gc, x, y, s, prop, angle)
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 131, in draw_mathtext
x = int(x) + ox
File "/usr/local/lib/python2.7/site-packages/numpy/ma/core.py", line
3795, in __int__
raise MaskError, 'Cannot convert masked element to a Python int.'
numpy.ma.core.MaskError: Cannot convert masked element to a Python int.
Traceback (most recent call last):
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 395, in expose_event
self._render_figure(self._pixmap, w, h)
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 75, in _render_figure
FigureCanvasAgg.draw(self)
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 401, in draw
self.figure.draw(self.renderer)
File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py",
line 884, in draw
func(*args)
File
"/usr/local/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py",
line 210, in draw
ax.draw(renderer)
File
"/usr/local/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axis3d.py",
line 393, in draw
tick.draw(renderer)
File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axis.py", line
234, in draw
self.label1.draw(renderer)
File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/text.py", line
591, in draw
ismath=ismath)
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 142, in draw_text
return self.draw_mathtext(gc, x, y, s, prop, angle)
File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 131, in draw_mathtext
x = int(x) + ox
File "/usr/local/lib/python2.7/site-packages/numpy/ma/core.py", line
3795, in __int__
raise MaskError, 'Cannot convert masked element to a Python int.'
numpy.ma.core.MaskError: Cannot convert masked element to a Python int.
any insight will be welcomed !
Thanks
···
--
RHENOVIA - Arnaud LEGENDRE.