Matplotlib - set bars different color depending on where they are located on the x axis -


i made bar plot in matplotlib , change color of bars either green or yellow depending on located on x-axis. example, bars represent data x values in [5, 6, 8, 9] should colored in yellow, while other bars should green. how do that? thank you!

first, nice if posted code.i suggest read information provided on matplotlib.org see possible options of function using. here code example:

import numpy np import matplotlib.pyplot plt x  = np.arange(10) xx = x**2 cr = ['g','g','g','g','y','y','y','y','g','g'] fig,ax = plt.subplots() ax.bar(x,xx,color=cr) plt.show() 

this produces:

enter image description here


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -