#!/usr/bin/env python # coding: utf-8 # In[1]: from lets_plot import * # In[2]: LetsPlot.setup_html() # In[3]: def_min_exp, def_max_exp = -7, 7 values = [3.14 * 10**d for d in range(def_min_exp, def_max_exp)] # In[4]: def plot(f=None): t = layer_tooltips().line("@v") if f is not None: t = t.format("@v", f) return ggplot({'v': values}, aes(y='v')) + \ geom_point(x=0, tooltips=t) + \ geom_text(aes(label='v'), x=1, label_format=f) + \ scale_x_continuous(limits=[-.5, 2]) + \ scale_y_log10(limits=[10**def_min_exp, 10**def_max_exp], format=f) + \ ggsize(400, 600) + \ ggtitle("Default format" if f is None else 'format="{0}"'.format(f)) # ## Without `theme()` # In[5]: plot().show() plot("g").show() # ## With `theme(exponent_format=('pow', -2, 3))` # In[6]: (plot() + theme(exponent_format=('pow', -2, 3))).show() (plot("g") + theme(exponent_format=('pow', -2, 3))).show()