Matplotlib > Fill plot (customized)

Name
Code
Output
# Data
x = numpy.linspace(1,5,100)
y1 = numpy.max(x)**2-x**2
y2 = x**2
# New Figure
fig = matplotlib.pyplot.figure(figsize=(7,4),facecolor='silver')
# New Axes
ax = fig.add_subplot(111,facecolor='azure')
# Add grid
ax.grid(color='b', linestyle='-', linewidth=0.5)
# Plot the data
matplotlib.pyplot.fill(x,y1,'red',zorder=1,alpha=0.5)
matplotlib.pyplot.fill(x,y2,'green',zorder=2,alpha=0.5)
ax.set(title="Plot title", xlabel="x axis", ylabel="y axis") 
# Fit the plot layout
matplotlib.pyplot.tight_layout()
# Show the plot
matplotlib.pyplot.show()

       
           Fill plot (customized)