so have created bar graph having trouble overlapping bars. thought problem edges overlapping, when changed edges='none'the bars slim.
i believe math correct in assuming 3 bars width of of .3 should moving along x axis .3 , leaving .1 gap between each set of bars. (note x increasing 1)
i don't see why bars end overlapping , overlap seems worse near end of graph.
ax = plt.subplot(111) ax2 = ax.twinx() ax.bar(x,ewtot,width=.3, color='b', align='center',label='eyewall',edgecolor='b') ax.bar(x + 0.3,ictot,width=.3, color='g', align='center',label='inner core',edgecolor='g') ax.bar(x + 0.6,rbtot,width=.3, color='r', align='center',label='rainband',edgecolor='r')
i think combination of 2 factors. first increase precision of width , x-position little supplying digits, or specifying them fraction.
secondly use of edge (linewidth > 0) makes bars overlap little default, edge centered, half edge inside bar, other half outside. disabling edge entirely prevents overlap.
increasing linewidth , setting alpha might identify whats going on exactly.
the example below illustrates this:
n = 10 x = np.arange(n) = np.random.rand(n) b = np.random.rand(n) c = np.random.rand(n) fig, axs = plt.subplots(2,1,figsize=(10,8)) axs[0].bar(x, a, width=0.3, facecolor='b', edgecolor='b', linewidth=3, alpha=.5) axs[0].bar(x+0.3, b, width=0.3, facecolor='r', edgecolor='r', linewidth=3, alpha=.5) axs[0].bar(x+0.6, c, width=0.3, facecolor='g', edgecolor='g', linewidth=3, alpha=.5) axs[1].bar(x, a, width=1/3, facecolor='b', alpha=.5, linewidth=0) axs[1].bar(x+1/3, b, width=1/3, facecolor='r', alpha=.5, linewidth=0) axs[1].bar(x+2/3, c, width=1/3, facecolor='g', alpha=.5, linewidth=0) 
Comments
Post a Comment