colorbar "NoneType" issue

Viewed 35

Here is an example of the graph where I am trying to change the tick label size. I had to take a unorthodox approach to get the colorbar added to the scatter plot via a seaborn/matplotlib using a modified version of this seen in the code below:

norm = plt.Normalize(df_xy[hue].min(), df_xy[hue].max())
sm = plt.cm.ScalarMappable(cmap = "Blues_r", norm = norm)
sm.set_array([])
sns.scatterplot(data = df_xy, x = 'value_RNAseq', y = 'value_RT-PCR', hue = hue, palette = "Blues_r")
title = name.split('_')[-1]
plt.colorbar(sm).set_label(title, fontsize = 15)
plt.legend().remove()

Normally code looks like this for an example:

cbar = fig.colorbar(surf, shrink=0.5, aspect=20, fraction=.12,pad=.02) 
cbar.set_label('Activation',size=18)
cbar.ax.tick_params(labelsize=5)

The issue I am running into is using this approach the colorbar returns TypeError: 'NoneType' object is not callable. The solution here addresses my currnet issue but I am struggling to implement the solution as I need/want a scatter plot and not the plt.imshow

I use a long form dataframe via pandas and then graph using seaborn as seen above. Here is a few lines of what my data looks like: chunk of excel

0 Answers
Related