`add_glow_effects(gradient_fill=True)` treats step plot like a line plot
diceroll123 opened this issue ยท 5 comments
I've found a possible band-aid solution, but I'm not very happy with it, nor do I trust it very much. and to be fair I have not tested this extensively yet, just sharing findings!
Since I can't for the life of me find anywhere that might have the points that are plotted as lines, besides the x and y values we pass in, I figure just manipulating the points in the gradient filler before it gets to this line, will get the job done.
The algorithm for mutating the X and Y values to make a Polygon into a pre
step plot is as follows:
x = x.repeat(2)
x = np.delete(x, -1)
y = y.repeat(2)
y = np.delete(y, 0)
And looks great!
Currently, I'm stumped on where in the code this could be generalized for all the different kinds of plots. plt.step(where=['mid', 'pre', 'post'])
I think the following works best, as it is using the auto-generated matplolib path instead of the data, it works out-of-the-box with every kind of plot ( 3 steps and the normal lines)
# xy = np.column_stack([x, y])
# xy = np.vstack([[xmin, Ay], xy, [xmax, Ay], [xmin, Ay]])
# clip_path = Polygon(xy, facecolor='none', edgecolor='none', closed=True)
# ax.add_patch(clip_path)
# im.set_clip_path(clip_path)
path = line.get_path()
extras = Path([[xmax,Ay],[xmin, Ay]], np.full(2, Path.MOVETO))
extras.codes[:] = Path.LINETO
path = path.make_compound_path(path, extras)
im.set_clip_path(path, line._transform)
Ahhh you found what I was looking for, awesome!
Thanks to @cedrichol, this should be implemented with #20 and published in v0.6.0. @diceroll123 feel free to check!
Works great.