matplotlib Flashcards Preview

Physics > matplotlib > Flashcards

Flashcards in matplotlib Deck (5)
Loading flashcards...
1
Q

How to produce a scatter graph and label the axis

A

import matplotlib.pyplot as plt

plt. scatter(x, y)
plt. xlabel(‘label name’, fontsize = 20)
plt. ylabel(‘label name’, fontsize = 20)
plt. show()

2
Q

Adding a regression line and seeing its summary (regression table)

A

import statsmodels.api
x1 = sm.add_constant(x)
result = sm.OLS(y, x1).fit()
result.summary()

3
Q

Seaborn

A

This is a library based off matplotlib that can produce better data visualisations - they look a lot better

import seaborn as sns
sns.set()

4
Q

Analysing the regression table - coefficient table

A

Constant represents the y intercept

The number below this represents the gradient

These can be used to determine the equation of the regression line so it can be plotted

5
Q

R - squared

A

A measure of how close the data is fitted to the regression line

It is a value between 0 and 1 and the closer to one the better