I want to fill a custom plot similar to what a bar chart does. In the minimum working example below I want to fill e.g. the rectangular "x1=1.2 y1=till top, x2=till end, y2=till top". Unfortunately the below code renders not as expected (see picture). Any ideas?
import numpy as np
import matplotlib.pyplot as plt
def plot():
fig, ax = plt.subplots(1, 1)
# X, Y - POLYGON
c_x = [0,
0,
2,
3,
4,
4
]
c_y = [0,
2,
2,
2,
2,
0
]
x_1 = np.array(c_x)
y_1 = np.array(c_y)
ax.plot(x_1, y_1, color='black')
ax.fill_betweenx(y_1, x_1, y_1, where=(x_1 > 1.2), interpolate=True)
ax.axis('equal')
plt.show()
plot()
Unfortunately the code renders like this... enter image description here