How can I adjust width of a bar graph's bars. An image has been attached with this post, which shows the actual condition. As we can see the labels, showing years, from 2011 to 2015.
I am finding a solution to reduce down the width of respective bars along the yaxis. Many random solutions were tried by me which is available here and there on line but nothing has worked.
The given image is actually a 3D graph but due to clear view only 2D picture has been shown.
Please help:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
data = np.array([[0,6,3,0,0,0,0,0,0,0,0,2,2,3,0,2,2,3,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,2,2,0,0,0,0,0,0,0,2],
[3,3,5,3,3,0,0,0,0,0,0,0,0,0,3,4,0,0,4,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,2,0,0],
[0,0,7,5,0,10,5,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,2,4,3,3,2,0,0,0,0,0,3,2,3,2,3,0,0,0,0,0,0,0,0,3,0],
[0,0,0,4,0,2,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0],
[5,0,2,2,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,2,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0], ])
#data = data.transpose()
row_names = ['Ch','Bi','Ba','Ho','Ja','Pu','N','Ga','Ke','Ma','Me','Ti','Ka','Th','Di','Wa','Ha','My','Tu','Ma','Bi','Ut Ka','Ra','Da','Ch','Ko','B','Bid','Gu','D&N','Ra','Pu','San','Dhu','Jal','Gon','Gand','Alw','Jal','SAS','Gur','Pat','Hos','Lu','Pan','Kur','Jan']
column_names = ["2011","2012","2013","2014","2015"]
fig = plt.figure()
ax = Axes3D(fig)
xpos = np.arange(0,lx,1)
ypos = np.arange(0,ly,1)
xpos, ypos = np.meshgrid(xpos+0.5, ypos+0.5)
xpos = xpos.flatten()
ypos = ypos.flatten()
zpos = np.ones(lx*ly)*1e-10
dx = 1. * np.ones_like(zpos)
dy = dx.copy()
dz = data.flatten()
print dz
cs = ['r', 'g', 'b', 'y', 'c'] * ly
values = np.linspace(0.2, 1., xpos.ravel().shape[0])
colors = cm.rainbow(values)
ticksx = np.arange(1, len(row_names)+1,1)
plt.xticks(ticksx, row_names)
z_data = np.random.rand(0,10)
ticksy = np.arange(0.5, len(column_names),1)
plt.yticks(ticksy, column_names)
#ax.tick_params(width=2, colors='r')
ax.w_xaxis.set_ticklabels(row_names,rotation=90,size=12)
ax.w_yaxis.set_ticklabels(column_names,rotation=40,size=12)
ax.bar3d(xpos,ypos,zpos, dx, dy, dz, alpha=0.7, zsort='max',color=colors)
plt.ion()
plt.show()
raw_input(" " )
update: Reducing the "dx" value by 1 to 0.5, reduces the bar width but now its showing the huge padding between the bars which i want to remove completely.
Last Update: I have attached one more Image. I am expecting this kind of 3D bar graph with reduced bar width (its done), and minimised gap between bars.