I am stuck while styling the line plot in in jupyter_notebook

40 Views Asked by At

Straight to the point: I wrote code for lineplot but when I tried to change its style to "dark", I failed.

Here is the code that I tried, can someone make correction, please!

import seaborn as sns
import matplotlib.pyplot as plt
phool = sns.load_dataset("iris")
phool
sns.lineplot(x="petal_length", y="petal_width", data=phool)
plt.title("Flower's bed")

# style changing
sns.set_style("dark")

plt.show()
1

There are 1 best solutions below

0
Timeless On

In your case, just run the cell twice (in the same kernel session) because Jupyter will remember the seaborn style. Or even better, move back set_style before lineplot :

sns.set_style("dark")

phool = sns.load_dataset("iris")

sns.lineplot(x="petal_length", y="petal_width", data=phool)
plt.title("Flower's bed")

plt.show();

You can also make it temporary styled-plot with axes_style :

with sns.axes_style("dark"):
    sns.lineplot(x="petal_length", y="petal_width", data=phool)

Output :

enter image description here