1

Is there a Python package or library which allows data to be visualised in a similar way to the data bar (gradient fill) conditional formatting of Microsoft Excel:

gradient fill

If not gradient fill, the perhaps solid fill like this:

solid fill

I'm wondering whether Pandas or another Python library has this functionality?

Alan
  • 509
  • 4
  • 15
  • 2
    The matplotlib docs have a tutorial on that [topic](https://matplotlib.org/3.1.3/gallery/lines_bars_and_markers/gradient_bar.html). – Paul Brodersen Feb 24 '20 at 10:34
  • 1
    There are also posts such as [this one](https://stackoverflow.com/questions/38830250/how-to-fill-matplotlib-bars-with-a-gradient) – JohanC Feb 24 '20 at 13:06

1 Answers1

1

Some sample data would have been handy.

Generate data :

data ={'MM-DD':['Jan-01-2019', 'Feb-02-2019', 'Mar-03-2019', 'Apr-04-2019', 'May-05-2019', 'Jun-06-2019','Jul-07-2019', 'Aug-08-2019', 'Sep-09-2019', 'Oct-10-2019', 'Nov-11-2019', 'Dec-12-2019'], 'clients':[12, 34, 67, 2, 12, 17,2, 5, 43, 32, 2, 7]}
df=pd.DataFrame.from_dict(data)
df



 df.set_index(df['MM-DD'], inplace=True)
 df['Dates']=df.index.strftime('%b-%d')

Plot in matplotlib library

import matplotlib .pyplot as plt
plt.barh( df['Dates'],df['clients'])
plt.ylabel('Dates')
plt.title('2018')
plt.show

enter image description here

Can also use seaborn library

import seaborn as sns
ax = sns.barplot(x=df['clients'], y=df['Dates'])
plt.title("2018")

enter image description here

wwnde
  • 26,119
  • 6
  • 18
  • 32