In the plt.savefig() call, you can use facecolor and edgecolor and many other options to modify the figure before saving it to the chosen format. We will explore some of those in the following recipes.
By default, Matplotlib looks at the file extension specified in the file name to decide in which format the figure needs to be saved. You can also use the format argument to specify the output format, in which case it will ignore the file extension specified and save the figure in the format specified in the format argument. However, your file reader may get confused with the mis-match in the file extension and the actual format in which it is saved when you try to open it.