I would like to customize the axes shadow in a matplotlib plot. the shadow looks unpropotionate to the other patches i am adding to the plot. I need dx and dy to be at least 4 to show the perspective I am looking for. as the only parameter is a boolean axes there is no way to control the shadow depth. I am trying to create the Shadow object myself and adding it to the legend but its not working correctly. please find herein an exemple
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 shows up on the screen the shadow is not drawn, It appear when I start resizing and sets behind the legend or near is in a weird way depending on how you resize. this is a snapshot of my weird shadow before and after resizing