Controlling Figure Aesthetics
As we mentioned previously, Matplotlib is highly customizable. But it also has the effect that it is very inconvenient, as it can take a long time to adjust all necessary parameters to get your desired visualization. In Seaborn, we can use customized themes and a high-level interface for controlling the appearance of Matplotlib figures.
The following code snippet creates a simple line plot in Matplotlib:
%matplotlib inline import matplotlib.pyplot as plt plt.figure() x1 = [10, 20, 5, 40, 8] x2 = [30, 43, 9, 7, 20] plt.plot(x1, label='Group A') plt.plot(x2, label='Group B') plt.legend() plt.show()
This is what the plot looks with Matplotlib's default parameters:
To switch to the Seaborn defaults, simply call the set()
function:
%matplotlib inline import matplotlib.pyplot as plt import seaborn as sns sns.set() plt.figure() x1 = [10, 20, 5, 40, 8] x2 = [30, 43,...