Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to plot side by side bar horizontal bar graph in python

import pandas
import matplotlib.pyplot as plt
import numpy as np

df = pandas.DataFrame(dict(graph=['Item one', 'Item two', 'Item three'],
                           n=[3, 5, 2], m=[6, 1, 3])) 

ind = np.arange(len(df))
width = 0.4

fig, ax = plt.subplots()
ax.barh(ind, df.n, width, color='red', label='N')
ax.barh(ind + width, df.m, width, color='green', label='M')

ax.set(yticks=ind + width, yticklabels=df.graph, ylim=[2*width - 1, len(df)])
ax.legend()

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: pd df replace 
Python :: torch distributed address already in use 
Python :: python detect script exit 
Python :: selenium error 403 python 
Python :: python decomposition facteur premier 
Python :: form field required in django views 
Python :: how to sort in python 
Python :: how to print list without newline 
Python :: python try 
Python :: import python code from another directory 
Python :: how to use drive link in pandas dataframe 
Python :: Forbidden (CSRF token missing or incorrect.): /extension/stripe-pay/ WARNING 2021-06-01 13:45:22,532 log 408 140165573588736 Forbidden (CSRF token missing or incorrect.): /extension/stripe-pay/ 
Python :: python parse /etc/resolv.conf 
Python :: dataframe concatenate 
Python :: spacy shortforms explanation 
Python :: maya python override color rgb 
Python :: hide verbose in pip install 
Python :: one line if statement python 
Python :: python switch 
Python :: python second interval 
Python :: python requests cannot find existing url 
Python :: regex in python 
Python :: read excel by row and output to txt 
Python :: standard streams with python3 
Python :: histogram relative frequency 
Python :: transform dictionary keys python 
Python :: python string [::-1] 
Python :: how to import ui file in pyside 
Python :: python += dictionary 
Python :: python - subtracting dictionary values 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =