I want to create a bubble chart using Bokeh based on categorical x-axis and y-axis and use count as their sizes.
Here's the data frame that I have, and I successfully created with Seaborn:
This is a brief version from Seaborn that I created
import pandas as pd
import seaborn as sns
d = {'T_range': ['0-50', '0-50', '0-50', '0-50',
'51-60', '51-60', '51-60', '51-60',
'61-70', '61-70', '61-70', '61-70'],
'Subject': ['English', 'Maths', 'Chinese', 'Arts',
'English', 'Maths', 'Chinese', 'Arts',
'English', 'Maths', 'Chinese', 'Arts'],
'count': [603, 240, 188, 89,
220, 118, 112, 43,
123, 2342, 32, 212]}
df_test = pd.DataFrame(data=d)
sns.set(rc={'figure.figsize':(15, 10)})
ax = sns.scatterplot(x='T_range', y='Subject', size='count', hue='Subject',
sizes=(100, 5000), legend=None, data=df_test)
display(df_test)
# Show result
ax
I would like to know how to achieve the same thing by using Bokeh. Thank you in advance.
Solved
Thanks to responders. I have managed to generate a graph exactly what I wanted. I have adjusted it a bit to suit application as follows:
x = df[range_name].tolist()
y = df[group_name].tolist()
size = list(map(lambda i: i/10, df['count'].tolist()))
d = {'{}'.format(range_name): x,
'{}'.format(group_name): y,
'count': size}