Home > other >  Matplotlib error AttributeError: 'AxesSubplot' object has no attribute 'bar_label
Matplotlib error AttributeError: 'AxesSubplot' object has no attribute 'bar_label

Time:03-30

 import numpy as np 
The import matplotlib
X=np. Arange (len (df_0_age) # the label locations
Width=0.35 # the width of the bars
Labels=df_0_age [' interval '] values
FIG, ax=PLT. Subplots ()
Rects1=ax. Bar (x - width/2, df_0_age [' proportion/ranking _ other '], width, label='other')
Rects2=ax. Bar (x + width/2, df_0_age [' proportion/ranking _ yunnan '], width, label='yunnan')

# Add some text for labels, the title and the custom x axis tick labels, etc.
Ax. Set_ylabel (' proportion ')
Ax. Set_title (' 0 ')
Ax. Set_xticks (x)
Ax. Set_xticklabels (labels)
Ax. Legend ()

Ax. Bar_label (rects1, padding=3)
Ax. Bar_label (rects2, padding=3)


I use a website with examples of this bar_label function is an error, version 3.3.4, with website didn't difference how many, should not version problem
  • Related