0

I am trying to subplot these 2 pandas bar plot but when I create a subplot the tags provided with xticks are deleted in the first subplot. I tried to plt.hold(True) but didn't solve the problem. What exactly is causing this error? You can find visualization of the problem and code below, thanks in advance.

fig, (ax1, ax2) = plt.subplots(1, 2)
#Get the first 10 common words by head
words_freq_head = pd.DataFrame(words_freq).head(10)
#Plot the first 10 common words
words_freq_head.plot.bar(ax=ax1)
#Set the label of common words on x axes
plt.xticks(np.arange(len(words_freq_head[0])), words_freq_head[0])

#Get the first 10 uncommon words by tail
words_freq_tail = pd.DataFrame(words_freq).tail(10)
#Plot the first 10 uncommon words
words_freq_tail.plot.bar(ax=ax2) 
#Set the label of uncommon words on x axes 
plt.xticks(np.arange(len(words_freq_tail[0])), words_freq_tail[0])

enter image description here

ned
  • 61
  • 1
  • 5

0 Answers0