Bokeh Annotation Overlapping Issue

Hi, I am pretty much new to bokeh. I am trying to plot a bubble chart and adding the column labels as an annotation there using Labelset. Some of These Labels are getting overlapped to each other and creating visual clutter in the graph. i have already tried x_offset, y_offset and label rotation to solve this issue, but none of them is working. Please guide me.
similar to what i am trying to accomplish - python - How to create a dynamic labelset on Bokeh that will avoid text overlapping? - Stack Overflow

Hi @Abhay_53 it’s not really possible to speculate at all without a complete Minimal Reproducible Example to see what you are seeing and what code you have tried.

Sure @Bryan , here is the example to reproduce the result

import numpy as np
import pandas as pd
from import output_notebook, output_file
from import show
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource, LabelSet
from bokeh.palettes import Spectral10

df_dict = {
    'Plans': ['ABC ValueCharge', 'Bizbazar 200CarbonNatural', 'EqualiserClient SuperSaverCombo'],
    'Rating': [17, 15, 14],
    'Sales': [1330.443, 1312.271, 1312.168],
    'Spends': [72.49, 47.7, 13.2417514]
df = pd.DataFrame.from_dict(df_dict)
p = figure(height = 600, width = 800, x_range = (0, 25), y_range = (800, 2000))
source = ColumnDataSource(data = df) = 'Rating', y = 'Sales', size = 'Spends',source = source,alpha = 0.8
p.xaxis.axis_label = "Rating"
p.yaxis.axis_label = "Sales"
labels = LabelSet(x='Rating', y='Sales', text='Plans', source = source,
                  x_offset= -50, y_offset=10, text_font_size = '7pt')


Here, is how the result looks like

Now the text annotation labels are getting overlapped to each other, which i wanted to avoid.

You may want to use individual Label annotations rather than LabelSet so that you can have more direct control over their placements.

Thanks @Bryan , though i’m wondering if we have anything in bokeh by which we can automatically detect and overcome this annotation overlapping.

No, there is no automatic dodging for labels.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.