Matplotlib

working with matplotlib for 2D graphing


In [1]:
import matplotlib.pyplot as plt
from matplotlib.offsetbox import AnchoredText
#import matplotlib.animation as animation

In [2]:
%matplotlib inline

In [3]:
weight =[258.1,257.1,256.6,257.7,257.6,254.3,252.5,252.6,251.7,251.2,250.1,247.8] 

#plot(weight, 'm', label='line1', linewidth=4)
plt.title('Q2 2017 - Progress on Weight Loss Program')
plt.grid(True)
plt.xlabel('Weigh in #')
plt.ylabel('Weight in Lbs.')
ax = plt.gca()
at = AnchoredText(
        "Rob's Weekly Weight Loss progress",
        loc=3, prop=dict(size=10), frameon=True,
    )
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
ax.add_artist(at)

plt.plot(weight,'m', linewidth=4, linestyle='dashed', marker='o', markerfacecolor='blue', markersize=10)


Out[3]:
[<matplotlib.lines.Line2D at 0x7f27c494f128>]

Dataframes

Working with Pandas and DataFrames. Importing necessary packages.


In [4]:
import pandas as pd
import numpy as np


---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-c046f915005f> in <module>()
----> 1 import pandas as pd
      2 import numpy as np

ModuleNotFoundError: No module named 'pandas'

In [ ]:
df = pd.DataFrame(data=np.array([[1,2,3,4], [5,6,7,8]], dtype=int), columns=['Pacific','Mountain','Central','Eastern'])
plt.plot(df)
df

LaTex usage for Math representations.

Any LaTeX math should be inside $$: $$c = \sqrt{a^2 + b^2}$$


In [ ]:
from IPython.display import display, Math, Latex
display(Math(r'\sqrt{a^2 + b^3}'))

In [ ]:
#%lsmagic

In [ ]:
#%quickref

In [ ]:
#%debug