def create_plot(): fig, ax = plt.subplots() line, = ax.plot([0, 1, 3, 8, 5], '-', lw=5) label = '<h1>Line {}</h1>'.format('A') plugins.connect(fig, plugins.LineHTMLTooltip(line, label)) ax.set_title('Line with HTML Tooltip') return fig
def __call__(self, plot, view): if not self._applies(plot, view): return fig = plot.handles['fig'] labels = [self.format_string.format(label=view.label)] tooltip = plugins.LineHTMLTooltip(plot.handles['line_segment'], labels, voffset=self.voffset, hoffset=self.hoffset, css=self.css) plugins.connect(fig, tooltip)
def __call__(self, plot, view): if not self._applies(plot, view): return fig = plot.handles['fig'] for key, bar in plot.handles['bars'].items(): handle = bar.get_children()[0] selection = [(d.name,{k}) for d, k in zip(plot.bar_dimensions, key) if d is not None] label_data = view.select(**dict(selection)).dframe().ix[0].to_frame() label = str(label_data.to_html(header=len(view.label)>0)) tooltip = plugins.LineHTMLTooltip(handle, label, voffset=self.voffset, hoffset=self.hoffset, css=self.css) plugins.connect(fig, tooltip)
def __call__(self, plot, view): if not self._applies(plot, view): return fig = plot.handles['fig'] df = view.dframe() labels = [] for i in range(len(df)): label = df.ix[[i], :].T label.columns = [view.label] labels.append(str(label.to_html(header=len(view.label)>0))) for i, (bar, label) in enumerate(zip(plot.handles['bars'].get_children(), labels)): tooltip = plugins.LineHTMLTooltip(bar, label, voffset=self.voffset, hoffset=self.hoffset, css=self.css) plugins.connect(fig, tooltip)