Home > database >  Matplotlib Barplot with Diverging Color Scheme
Matplotlib Barplot with Diverging Color Scheme

Time:09-24

I am trying to make a horizontal barplot with just one bar. Here is sample code:

import matplotlib.pyplot as plt
plt.figure(figsize=(4, 1))
plt.barh(['my_value'], height =0.1, width=[-1,1], align='center')
plt.axvline(x=0.8, color='black')

enter image description here

How can I add a diverging color scheme/palette to it? Such that the color transitions from left to right smoothly. Solutions using Seaborn will work too.

CodePudding user response:

You could adapt the solution from the gradient bar

  • Related