Adjust fontsize of labels

Is there a way to adjust fontsize of labels in plots thru jslink?

Relevant:

https://panel.holoviz.org/gallery/links/bokeh_property_editor.html#links-gallery-bokeh-property-editor
https://panel.holoviz.org/gallery/links/holoviews_glyph_link.html#links-gallery-holoviews-glyph-link

based on the topic you linked you can di this:

cmaps = matplotlib.pyplot.colormaps()
cmap_dict = {}

for cmap in cmaps:
    _cmap = matplotlib.cm.get_cmap(str(cmap), 12)
    cmap_dict[str(cmap)] = [matplotlib.colors.rgb2hex(_cmap(i)[:3]) for i in range(_cmap.N)]

def get_blank_plot():
    #p1 = hv.Curve([],kdims=["Date"],vdims=["Price [BTC]"]).opts(responsive=True)
    ls = np.linspace(0, 10, 200)
    xx, yy = np.meshgrid(ls, ls)
    
    p1 = hv.Image(np.sin(xx)*np.cos(yy),kdims=['x','y'],vdims=['z'])
    return p1

class Example(param.Parameterized):
    EXAMPLE_PLOT = get_blank_plot().opts(width=500,height=400)
    
    def __init__(self, **params):
        super().__init__(**params)
        
        self.plot_pane = pn.pane.HoloViews(self.EXAMPLE_PLOT)
        self.font_size = pn.widgets.IntInput(end=40,start=5,value=13,name='Font size')
        
        self.font_size.jslink(self.plot_pane, code={'value':'''
            xaxis.major_label_text_font_size = `${cb_obj.value-2}px`
            xaxis.axis_label_text_font_size = `${cb_obj.value}px`
            yaxis.major_label_text_font_size = `${cb_obj.value-2}px`
            yaxis.axis_label_text_font_size = `${cb_obj.value}px`
        '''})
        
    def panel(self):
        return pn.Column(self.font_size, self.plot_pane)
      
app = Example(name='')
app.panel()

dynamic_fontsize

1 Like

Thanks! This is super useful. Maybe panel can have a util dropdown method for post-tweaking to modify all these settings (colorbar + axis range + fontsize)

Yes I think it is a good idea to produce better plots live for presentation for exemple.
I search to make this class automatically but did it by hand at the end…

2 Likes

And I forget to mention that are is a nice exemple for bokeh !

https://panel.holoviz.org/gallery/links/bokeh_property_editor.html#links-gallery-bokeh-property-editor

2 Likes