# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# [Back to PyCampNextLevel Outline](PyCampNextLevel.ipynb)
#
# # HOME FROM SCHOOL?
#
# Don't let that keep you behind.
#
# Lets practice plotting functions to keep in shape!

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# %matplotlib inline

# [Explain that last command!](https://stackoverflow.com/questions/43027980/purpose-of-matplotlib-inline)

def parabola(x):
    return x * x


domain = np.linspace(-5,5,100) # a 100 points between [5, -5]

df = pd.DataFrame({"domain":domain, "range":[parabola(n) for n in domain]}) # slower

df.head()

# [DataFrame.plot](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html#pandas.DataFrame.plot)

df.plot(x="domain", y="range", title="PARABOLA");

df = pd.DataFrame({"domain":domain, "range":np.power(domain, 3)})  # faster than before
df.plot(x="domain", y="range", title="3RD POWER", color='orange');

df = pd.DataFrame({"domain":domain, "sine":np.sin(domain), "cosine":np.cos(domain)})

# +
# gca stands for 'get current axis'
ax = plt.gca()

df.plot(kind='line',x='domain',y='sine', color='orange', ax=ax)
df.plot(kind='line',x='domain',y='cosine', color='black', ax=ax)

plt.show();
# -

# [Back to PyCampNextLevel Outline](PyCampNextLevel.ipynb)

StarcoderdataJupyterScriptsDedupFiltered