i can't seem interactive tooltips powered mpld3 work fantastic lmplot-like scatter plots seaborn.
i'd love pointer on how work! thanks!
example code:
# i'm running in ipython notebook. %matplotlib inline import matplotlib.pyplot plt, mpld3 mpld3.enable_notebook() import seaborn sns n=10 data = pd.dataframe({"x": np.random.randn(n), "y": np.random.randn(n), "size": np.random.randint(20,200, size=n), "label": np.arange(n) }) scatter_sns = sns.lmplot("x", "y", scatter_kws={"s": data["size"]}, robust=false, # slow if true data=data, size=8) fig = plt.gcf() tooltip = mpld3.plugins.pointlabeltooltip(fig, labels=list(data.label)) mpld3.plugins.connect(fig, tooltip) mpld3.display(fig) i'm getting seaborn plot along following error:
javascript error adding output! typeerror: obj.elements not function see browser javascript console more details. the console shows:
typeerror: obj.elements not function @ mpld3_tooltipplugin.draw (https://mpld3.github.io/js/mpld3.v0.2.js:1161:9) @ mpld3_figure.draw (https://mpld3.github.io/js/mpld3.v0.2.js:1400:23) @ object.mpld3.draw_figure (https://mpld3.github.io/js/mpld3.v0.2.js:18:9) @ eval (eval @ <anonymous> (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231), <anonymous>:14:14) @ eval (eval @ <anonymous> (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231), <anonymous>:15:5) @ eval (native) @ function.x.extend.globaleval (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231) @ x.fn.extend.dommanip (https://mbcomp1:9999/static/components/jquery/jquery.min.js:5:21253) @ x.fn.extend.append (https://mbcomp1:9999/static/components/jquery/jquery.min.js:5:18822) @ outputarea._safe_append (https://mbcomp1:9999/static/notebook/js/outputarea.js:336:26) outputarea.js:319 javascript error adding output! typeerror: obj.elements not function @ mpld3_tooltipplugin.draw (https://mpld3.github.io/js/mpld3.v0.2.js:1161:9) @ mpld3_figure.draw (https://mpld3.github.io/js/mpld3.v0.2.js:1400:23) @ object.mpld3.draw_figure (https://mpld3.github.io/js/mpld3.v0.2.js:18:9) @ eval (eval @ <anonymous> (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231), <anonymous>:14:14) @ eval (eval @ <anonymous> (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231), <anonymous>:15:5) @ eval (native) @ function.x.extend.globaleval (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231) @ x.fn.extend.dommanip (https://mbcomp1:9999/static/components/jquery/jquery.min.js:5:21253) @ x.fn.extend.append (https://mbcomp1:9999/static/components/jquery/jquery.min.js:5:18822) @ outputarea._safe_append (https://mbcomp1:9999/static/notebook/js/outputarea.js:336:26) outputarea.js:338 typeerror: obj.elements not function @ mpld3_tooltipplugin.draw (https://mpld3.github.io/js/mpld3.v0.2.js:1161:9) @ mpld3_figure.draw (https://mpld3.github.io/js/mpld3.v0.2.js:1400:23) @ object.mpld3.draw_figure (https://mpld3.github.io/js/mpld3.v0.2.js:18:9) @ eval (eval @ <anonymous> (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231), <anonymous>:14:14) @ eval (eval @ <anonymous> (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231), <anonymous>:15:5) @ eval (native) @ function.x.extend.globaleval (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231) @ x.fn.extend.dommanip (https://mbcomp1:9999/static/components/jquery/jquery.min.js:5:21253) @ x.fn.extend.append (https://mbcomp1:9999/static/components/jquery/jquery.min.js:5:18822) @ outputarea._safe_append (https://mbcomp1:9999/static/notebook/js/outputarea.js:336:26) outputarea.js:319 javascript error adding output! typeerror: obj.elements not function @ mpld3_tooltipplugin.draw (https://mpld3.github.io/js/mpld3.v0.2.js:1161:9) @ mpld3_figure.draw (https://mpld3.github.io/js/mpld3.v0.2.js:1400:23) @ object.mpld3.draw_figure (https://mpld3.github.io/js/mpld3.v0.2.js:18:9) @ eval (eval @ <anonymous> (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231), <anonymous>:14:14) @ eval (eval @ <anonymous> (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231), <anonymous>:15:5) @ eval (native) @ function.x.extend.globaleval (https://mbcomp1:9999/static/components/jquery/jquery.min.js:4:4231) @ x.fn.extend.dommanip (https://mbcomp1:9999/static/components/jquery/jquery.min.js:5:21253) @ x.fn.extend.append (https://mbcomp1:9999/static/components/jquery/jquery.min.js:5:18822) @ outputarea._safe_append (https://mbcomp1:9999/static/notebook/js/outputarea.js:336:26)
i don't think there easy way currently. can of tooltips show replacing tooltip constructor following:
ax = plt.gca() pts = ax.get_children()[3] tooltip = mpld3.plugins.pointlabeltooltip(pts, labels=list(data.label)) this works points outside of uncertainty interval, though. think possible extend seaborn make these points highest in zorder , store them in in instance somewhere don't need pull them out of axis children list. perhaps worth feature request.
Comments
Post a Comment