0

I know this question has been asked before but their solution didn't help me. I have a dataframe of size (391,28) and I want to create a bubble chart like shown here:

bubble chart

My dataframe looks like:

#      A     B     C
# X    0     10    0
# Y    1     2     1

Here I show only a smaller dataframe to give an idea but like I said my dataframe is 391*28 big.

In order to create a bubble chart I do the following:

dfu = df.unstack().reset_index()
dfu.columns = list("XYS")

dfu["S"] *= 20

figure(figsize=(17, 15))
colors = np.random.rand(40)
plt.xticks(rotation=-15)
plt.scatter(x="X", y="Y", s="S", data=dfu)
plt.margins(.4)
plt.show()

But this produces categories on y-axis that are overlapping.

enter image description here

I tried increasing the size but it didn't help. Overlap stays the same. So How can I solve for this? Insights will be appreciated.

John
  • 815
  • 11
  • 31
  • 391*28 is very large, but I believe the y-axis tick labels should display without overlap if you make the figure large enough. Have you tried using `figsize=(28, 391)`? Maybe reducing or removing the margins can also help. – Patrick FitzGerald Jul 17 '21 at 17:50
  • Related questions: [Python - Categorical bubble plot](https://stackoverflow.com/q/50399802/14148248), [Seaborn/Matplotlib categorical plot markers size by count of observations](https://stackoverflow.com/q/60119971/14148248) – Patrick FitzGerald Jul 17 '21 at 17:51

0 Answers0