I have the following code for which only ax3 displays the plotting area and data. Subplots ax1 and ax2 display a plot area but no data. Ultimately, I want three plots (3, 1 configuration) with sharex=True. I'm using Python 2.7.2 and matplotlib 1.2.1
import numpy as np
import matplotlib.pyplot as plt
f, (ax1, ax2, ax3) = plt.subplots(3, 1, sharex=True, sharey=False)
f.subplots_adjust(wspace=0)
N = 4
ind = np.arange(N)
width = .4
group_names = ('A', 'B', 'C', 'D')
q2 = [84, 21, 10, 4]
q4 = [69, 34, 22, 0]
q6 = [66, 28, 17, 2]
colors = ['c', 'purple', 'g', 'red']
ax1 = plt.barh(ind, q2, width, color=colors)
plt.yticks(ind+width/N, group_names)
plt.ylim([min(ind)-0.25, max(ind)+0.65])
plt.xticks(np.arange(0, 110, 10.))
plt.xlim(0, 100)
ax2 = plt.barh(ind, q4, width, color=colors)
plt.yticks(ind+width/N, group_names)
plt.ylim([min(ind)-0.25, max(ind)+0.65])
plt.xticks(np.arange(0, 110, 10.))
plt.xlim(0, 100)
ax3 = plt.barh(ind, q6, width, color=colors)
plt.yticks(ind+width/N, group_names)
plt.ylim([min(ind)-0.25, max(ind)+0.65])
plt.xticks(np.arange(0, 110, 10.))
plt.xlim(0, 100)
plt.show()
plt.barh
here? Instead useax1.barh
, etc to plot directly to your axis. – celmatplotlib v1.2.1
is 2 and a half years old.1.4.3
is the current stable release. You might consider updating your version – tmdavison