Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Horizontal stacked percent bar chart - with dataframe, seaborn colormap

colors = sns.color_palette("Set2", n_colors = 4)
cmap = LinearSegmentedColormap.from_list("my_colormap", colors)

ax = df_pos_time.plot(kind = 'barh', stacked = True, figsize = (14, 7), colormap = cmap, ec = 'w')
plt.legend(loc = 'center left', bbox_to_anchor = (1.0, 0.5), fontsize = 14)

for p in ax.patches:
    left, bottom, width, height = p.get_bbox().bounds
    if width > 0:
         ax.annotate(f'{width:0.1f}%', xy=(left+width/2, bottom+height/2), ha='center', va='center', fontsize=13)

ax.xaxis.set_visible(False)
plt.box(False)
plt.yticks(fontsize=17)
Comment

PREVIOUS NEXT
Code Example
Python :: tuples of unique rows pandas 
Python :: pyqt qwidget background color 
Python :: dividing col in csv 
Python :: Delete files in folder by extension 
Python :: How to Merge QuerySets in Django Rest Framework 
Python :: python multiprocessing imap tqdm 
Python :: pandas python multiindex 
Python :: change form type flask from text to selection flask admin 
Python :: captcha.image install in python 
Python :: get_string python 
Python :: how to use + with strings 
Python :: method for format age in python 
Python :: add values to add value in a matplotlib image 
Python :: finns = False 
Python :: is python3 enough for react native 
Python :: Console code page (437) differs from Windows code page (1252) 8-bit characters might not work correctly 
Python :: python faculty of 0 is 1 faculty of 1 is 1 
Python :: mass algorithm python 
Python :: say something in discord discord.py 
Python :: how to get entitys of word using pytho nlp 
Python :: Return a new RDD containing only the elements that satisfy a predicate. 
Python :: there is no difference in R between a string scalar and a vector of strings 
Python :: copy constructor python 
Python :: difference between calling a function and referencing a function python 
Python :: pandas save csv list as columns 
Python :: use colabs gpu locally 
Python :: python numpy + opencv + overlay image 
Python :: why video is not writing opencv 
Python :: *args **kwargs together in python 
Python :: Display all resources in table pandas 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =