在 MPLD3 中取消隐藏工具栏

Unhide toolbar in MPLD3

是否有现有的 mpld3 插件可以阻止工具栏自动隐藏?总的来说,我试图让工具栏更显眼,所以任何修改工具栏的现有插件(使其更大、更不透明等)都会有所帮助。我看到了 this 的回答,但不幸的是,我认为我的知识还不够 javascript 以了解如何将其概括为修改工具栏的其他部分。

可以调整 TopToolbar 示例来制作持久性工具栏。这个 javascript 东西有点繁琐,所以这是代码,如果您想了解更多详细信息,请告诉我。

class TweakToolbar(plugins.PluginBase):
    """Plugin for changing toolbar"""

    JAVASCRIPT = """
    mpld3.register_plugin("tweaktoolbar", TweakToolbar);
    TweakToolbar.prototype = Object.create(mpld3.Plugin.prototype);
    TweakToolbar.prototype.constructor = TweakToolbar;
    function TweakToolbar(fig, props){
        mpld3.Plugin.call(this, fig, props);
    };

    TweakToolbar.prototype.draw = function(){
      // the toolbar svg doesn't exist
      // yet, so first draw it
      this.fig.toolbar.draw();

      // then change the toolbar as desired

      // show toolbar
      this.fig.toolbar.buttonsobj.transition(750).attr("y", 0);

      // remove event triggers
      this.fig.canvas
        .on("mouseenter", null)
        .on("mouseleave", null)
        .on("touchenter", null)
        .on("touchstart", null);


      // then remove the draw function,
      // so that it is not called again
      this.fig.toolbar.draw = function() {}
    }
    """
    def __init__(self):
        self.dict_ = {"type": "tweaktoolbar"}

Here is a notebook that shows it in context.