I want to customize my simple bar plot based on frequency of data. Context as follows:
I have a data set, where x-axis is referred to as var_change and y-axis as var_median and error-bars as var_error. The var_change and var_error are calculated at the bin size of 5-var_median. The code and the plot for these variables is shown below:
fig = plt.figure(figsize=(24,7))
ax = [plt.subplot(181)]
ax[i].barh(np.arange(0+2.5,99+2.5,5), var_change, alpha = 0.6, height = 5,
color='none', edgecolor='k', capsize=2.5, lw = 0.8)
ax[i].errorbar(var_change, np.arange(0+2.5,99+2.5,5), xerr = var_error, capsize=3,
fmt="r:o", ecolor = "black", alpha = 0.8)
I want to independently control both line-width (lw in barh), and alpha in errorbar, as well as color of individual bars in the bar plot below based on frequency of the data set. The frequency can be calculated using the code below:
#df_delta_pos is a data-frame
pos_count = []
for j in np.arange(0,99,5):
pos_count.append(df_delta_pos.where((df.var_median> TC_bins[j]) &
(df.var_median<= TC_bins[j+5])).dropna()['var_change'].count())
#Here I would also normalize them if changing 'lw'. Code for normalization can be provided, if needed.
#For now consider random numbers here.
The final plot should look something like below, but also with change in lw and alpha based on frequency.

