python - is there a way to add 2 yticks and 2 bars in one matplotlib plot? -


hello want ask if there way add yticks bars in same plot?

this example:
https://image.ibb.co/jxsugf/untitled.jpg

here possible way, using ax.set_yticklabels:

enter image description here

import matplotlib.pyplot plt  import numpy np; np.random.seed(0)  x = np.arange(8) y1 = np.random.rand(4) y2 = np.random.rand(4)  fig, ax = plt.subplots() ax.barh(x[::2], y1, color="c3") ax.barh(x[1::2], y2, color="c0")  t = range(len(x)) ax.set_yticks(t) t[0::2] = ["another tick"]*(len(x)/2) t[1::2] = ["tick {}".format(i+1) in range((len(x)/2))] ax.set_yticklabels(t) plt.tight_layout() plt.show() 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -