Matplotlib

working with matplotlib for 2D graphing


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

In [11]:
%matplotlib inline

In [14]:
weight =[258.1,257.1,256.6,257.7,257.6,254.3,252.5,252.6,251.7] 

#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 Daily 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[14]:
[<matplotlib.lines.Line2D at 0x10e2b03c8>]

Dataframes

Working with Pandas and DataFrames. Importing necessary packages.


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

In [5]:
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


Out[5]:
Pacific Mountain Central Eastern
0 1 2 3 4
1 5 6 7 8

LaTex usage for Math representations.

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


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


$$\sqrt{a^2 + b^3}$$

In [7]:
#%lsmagic

In [8]:
#%quickref

In [9]:
#%debug

In [ ]: