0
Hallo, ich möchte fragen, ob es eine Möglichkeit gibt, weitere yticks mit Balken in der gleichen Handlung hinzuzufügen?
gibt es eine Möglichkeit, 2 Yticks und 2 Bars in einem Matplotlib-Plot hinzuzufügen?
Hallo, ich möchte fragen, ob es eine Möglichkeit gibt, weitere yticks mit Balken in der gleichen Handlung hinzuzufügen?
gibt es eine Möglichkeit, 2 Yticks und 2 Bars in einem Matplotlib-Plot hinzuzufügen?
Hier ist eine Art und Weise, mit ax.set_yticklabels
:
import matplotlib.pyplot as plt
import numpy as 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) for i in range((len(x)/2))]
ax.set_yticklabels(t)
plt.tight_layout()
plt.show()
Was haben Sie versucht, so weit
Dies wäre ein Beispiel? Ziehen Sie in Betracht, ein minimales, vollständiges und überprüfbares Beispiel (http://stackoverflow.com/help/mcve) hinzuzufügen, um nützliche Antworten auf dieser Site zu erhalten –