Shadowplotlib shadow axis settings

I would like to adjust the shadow of the axes in the matplotlib plot. the shadow looks unsuitable for the other patches that I add to the plot. I need dx and dy to be at least 4 to show the perspective I'm looking for. since the only parameter is the boolean axis, there is no way to control the depth of the shadow. I am trying to create a Shadow object myself and add it to the legend, but it does not work correctly. please find an example here

import wx
import numpy as np
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure
from matplotlib.legend import Legend
from matplotlib.patches import Shadow
from matplotlib.axes import Axes
from matplotlib.lines import Line2D

class Frame(wx.Frame):
    def __init__(self):
        # initialize
        wx.Frame.__init__(self, None)
        # create main sizer
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        # create figure, canvas and matplotlib toolbar
        self.figure = Figure(figsize=(4.5,4), dpi=None)
        self.canvas = FigureCanvasWxAgg( self, -1, self.figure )
        # add canvas to sizer
        mainSizer.Add(self.canvas, proportion=1, flag=wx.ALL|wx.EXPAND)
        self.SetSizer(mainSizer)
        mainSizer.Fit(self)
        self.Show(True)  

# create parabola data to plot
data = np.array(range(100))**2/100.
# start the plot
app = wx.App(0)      
frame = Frame()
axes = frame.figure.add_axes((0.1,0.1,0.8,0.8))
# add line 
line = Line2D(xdata=range(len(data)), ydata=data)
axes.add_line(line)
# set axes limits
axes.set_xlim(left=0,right=len(data))
axes.set_ylim(bottom=data[0],top=data[-1])
# create legend
l = Legend(axes,[line],['parabola'], shadow=False)
s = Shadow(l.legendPatch, 5, -5)
# add legend and shadow to axes
axes.legend_ =l
axes.add_patch(s)
# draw canvas                 
frame.canvas.draw()

app.MainLoop()

when the frame is displayed on the screen, the shadow is not drawn, it appears when I start to resize and sets strange or legend behind the legend, depending on how you resize. this is a snapshot of my weird shadow before and after resizing

This is the plot just when it got drawn before any resizing.  no shadow !!!

This is the plot after some resizing.  Shadow is disproportionate and resizes weirdly

+4

All Articles