Mpld3: Comment changer l'emplacement de la barre d'outils à l'aide d'un plugin?

La barre d'outils pour les écrans mpld3 se trouve habituellement dans le coin inférieur droit de l'écran. J'aimerais qu'il soit dans le coin supérieur droit de l'écran. Il semble que le code qui contrôle la position de la barre d'outils puisse être localisé ici .

J'aimerais savoir comment sélectionner l'objet de la barre d'outils en utilisant Javascript afin que je puisse changer son emplacement. Le code Javascript serait idéalement l'attribut d'un plugin mpld3 personnalisé.

Voici un simple plugin mpld3 pour déplacer la barre d'outils vers le haut d'une figure:

 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"} 

Vous pouvez le voir en action dans un cahier ici .