import matplotlib.pyplot as plt # Create figure with two subplots fig, (ax1, ax2) = plt.subplots(2, 1) # Plot data on ax1 and ax2 ax1.plot([1, 2, 3], [4, 5, 6], label='line 1') ax2.scatter([1, 2, 3], [4, 5, 6], label='points') # Add legends to each subplot ax1.legend() ax2.legend() # Show the figure plt.show()This code creates a figure with two subplots, each of which contains different types of plots (a line plot and a scatter plot). The `label` argument is used to define a descriptive label for each plot. The `legend` method is then called on each subplot to add a legend to the plot. The resulting figure shows the two subplots with their respective legends. The package library used in this example is Matplotlib.