Multiple problems involving `ax.axhline` with mplcyberpunk
diceroll123 opened this issue · 1 comments
diceroll123 commented
Consider the following code:
plt.style.use("cyberpunk")
ax = plt.gca()
ax.axhline(y=1, color="#C20000") # draw a red line across the X axis, y=1
ax.step(range(7), [0, 1, 2, 3, 2, 1, 0], marker="o")
mplcyberpunk.add_glow_effects()
plt.show()
The area filled in with red underneath the blue is inconsistent, showing where x <= 1
, I'd expect to see it at x >= 5
here.
That wasn't even why I started writing the issue, I found it while making my test case to showcase the error I found -- but I figured I'd bring it up.
The initial reason I was making an issue was because using ax.axhline
with mplcyberpunk.add_glow_effects(gradient_fill=True)
throws an AttributeError.
plt.style.use("cyberpunk")
ax = plt.gca()
ax.axhline(y=1, color="#C20000") # draw a red line across the X axis, y=1
ax.step(range(7), [0, 1, 2, 3, 2, 1, 0], marker="o")
mplcyberpunk.add_glow_effects(gradient_fill=True) # this is the only line changed from the above example
plt.show()
Traceback:
Traceback (most recent call last):
File "test.py", line 17, in <module>
main()
File "test.py", line 12, in main
mplcyberpunk.add_glow_effects(gradient_fill=True)
File ".../mplcyberpunk/core.py", line 18, in add_glow_effects
add_gradient_fill(ax=ax)
File ".../mplcyberpunk/core.py", line 126, in add_gradient_fill
xmin, xmax = x.min(), x.max()
AttributeError: 'list' object has no attribute 'min'
This is because the line is a list of tuples, rather than a numpy array.
The tests for mplcyberpunk could be more strict I suppose.
dhaitz commented
thanks for reporting this, should be fixed in the latest version!