@@ -102,6 +102,26 @@ def add_legend_at(fig, position='right'):
102102 "width" : int (DEFAULT_FIGURE_WIDTH * 1.5 ),
103103 "height" : int (DEFAULT_FIGURE_HEIGHT * 1.5 )}
104104}
105+ pie_theme = {
106+ "figure_kwargs" : {
107+ "background_fill_color" : '#00000000' , #transparent
108+ "border_fill_color" : '#00000000' ,
109+ # Note: No x_range.range_padding for pie charts as they use numeric ranges
110+ "xgrid.grid_line_color" : None ,
111+ "xaxis.major_label_orientation" : 1 ,
112+ "title.text_font_size" : '18px' ,
113+ "yaxis.axis_label_text_font_size" : '18px' ,
114+ "xaxis.axis_label_text_font_size" : '18px' ,
115+ "xaxis.major_label_text_font_size" : '16px' ,
116+ "yaxis.major_label_text_font_size" : '16px' ,
117+ "toolbar.logo" : None ,
118+ "toolbar_location" : "right" ,
119+ "legend.location" : "top_right" ,
120+ "legend.orientation" : "vertical" ,
121+ "legend.click_policy" : "hide" ,
122+ "width" : DEFAULT_FIGURE_WIDTH ,
123+ "height" : DEFAULT_FIGURE_HEIGHT }
124+ }
105125
106126
107127
@@ -273,7 +293,7 @@ def bokeh_barchart(df, x='x_value', y=['y_value'], factors=None, figure=None, da
273293 return fig
274294
275295# bokeh piechart
276- @apply_theme ()
296+ @apply_theme (theme = pie_theme )
277297def bokeh_piechart (df , x = 'x_value' , y = ['counts' ], figure = None , outer_radius = 0.7 , inner_radius = 0.4 ,
278298 title = '' , fill_color = None , legend_labels = None , line_color = 'black' , ** kwargs ):
279299 """Draw an interactive piechart with bokeh
@@ -369,13 +389,17 @@ def bokeh_piechart(df, x='x_value', y=['counts'], figure=None, outer_radius=0.7,
369389
370390 tools = 'hover,wheel_zoom,box_zoom,undo,reset,save'
371391 if figure is None :
392+ x_range = (- 1.2 , 1.2 ) # Give some padding around the pie chart
393+ y_range = (0.2 , 1.8 ) # Give some padding around the pie chart
372394 fig = bokeh_figure (height = DEFAULT_FIGURE_HEIGHT , width = DEFAULT_FIGURE_WIDTH ,
373395 title = title ,
374396 toolbar_location = 'above' ,
375397 tools = tools ,
376398 tooltips = [('Data' , f'@{ x } ' ),
377399 ('Percentage' , '@percent{0.00%}' ),
378- ('Count' , f'@count' )])
400+ ('Count' , f'@count' )],
401+ x_range = x_range ,
402+ y_range = y_range )
379403 else :
380404 fig = figure
381405
0 commit comments