3
mpld3显示的工具栏通常位于屏幕的右下角。我希望它位于屏幕的右上角。看起来好像控制工具栏位置的代码可以位于here。mpld3:如何使用插件更改工具栏的位置?
我想知道如何选择使用Javascript的工具栏对象,以便我可以改变它的位置。该Javascript代码理想情况下是一些自定义mpld3插件的属性。
mpld3显示的工具栏通常位于屏幕的右下角。我希望它位于屏幕的右上角。看起来好像控制工具栏位置的代码可以位于here。mpld3:如何使用插件更改工具栏的位置?
我想知道如何选择使用Javascript的工具栏对象,以便我可以改变它的位置。该Javascript代码理想情况下是一些自定义mpld3插件的属性。
下面是一个简单mpld3
插件工具栏移动到图的顶部:
class TopToolbar(plugins.PluginBase):
"""Plugin for moving toolbar to top of figure"""
JAVASCRIPT = """
mpld3.register_plugin("toptoolbar", TopToolbar);
TopToolbar.prototype = Object.create(mpld3.Plugin.prototype);
TopToolbar.prototype.constructor = TopToolbar;
function TopToolbar(fig, props){
mpld3.Plugin.call(this, fig, props);
};
TopToolbar.prototype.draw = function(){
// the toolbar svg doesn't exist
// yet, so first draw it
this.fig.toolbar.draw();
// then change the y position to be
// at the top of the figure
this.fig.toolbar.toolbar.attr("y", 2);
// then remove the draw function,
// so that it is not called again
this.fig.toolbar.draw = function() {}
}
"""
def __init__(self):
self.dict_ = {"type": "toptoolbar"}
您可以在a notebook here看到它的行动。
这工作完美。非常感谢。 – mattcart 2014-10-27 18:53:34