Question #319424

  1. How you import Matplotlib and Seaborn? What are the common aliases used while importing these modules?
  2. What is the purpose of the magic command %matplotlib inline?
  3. How do you plot a line chart in Python? Illustrate with an example.

Expert's answer

1.

import matplotli.pyplot as plt
import seaborn as sns

plt and sns are common abbreviations for Matplotlib and Seaborn respectively.


2.

The magic command %matplotlib inline allows to include graphs in a notebook


3.

import seaborn as sns
import matplotlib.pyplot as plt
import math

sns.set_theme(style="whitegrid")
X = [0.1*i for i in range(100) ]
Y = [math.sin(x) for x in X]
sns.lineplot(x=X, y=Y)
plt.show()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS