0% found this document useful (0 votes)
68 views4 pages

Intro To Ipynb

This document introduces Jupyter notebooks and demonstrates various plotting capabilities in Python. It shows how to print text, comments, import libraries, generate test data, and create line plots, bar plots and subplots of simple functions and data using Matplotlib and Pandas. Key capabilities include generating sine waves, parabolas, bar plots of sample data, and arranging multiple plots in a grid using subplots. The document is an introductory tutorial on scientific computing and data visualization in Jupyter notebooks.

Uploaded by

api-296946581
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views4 pages

Intro To Ipynb

This document introduces Jupyter notebooks and demonstrates various plotting capabilities in Python. It shows how to print text, comments, import libraries, generate test data, and create line plots, bar plots and subplots of simple functions and data using Matplotlib and Pandas. Key capabilities include generating sine waves, parabolas, bar plots of sample data, and arranging multiple plots in a grid using subplots. The document is an introductory tutorial on scientific computing and data visualization in Jupyter notebooks.

Uploaded by

api-296946581
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Intro to ipynb

December 11, 2015


In [1]: print "Hello World"
Hello World
In [3]: print "My first lesson in scientific computing"
My first lesson in scientific computing
In [4]: #THIS IS HOW YOU MAKE A COMMENT
#PYTHON IS ALSO A CALCULATOR
In [5]: import matplotlib
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [6]: x = np.linspace(0, 3*np.pi, 500)
plt.plot(x, np.sin(x**2))
plt.title(A simple chirp)
plt.show()

In [8]: x = np.linspace(-10, 10, 500)


plt.plot(x, x**2)
plt.title(A parabola opening upward)
plt.show()

In [9]: x = np.linspace(-10, 10, 500)


plt.plot(x, -x**2)
plt.title(A parabola opening downward)
plt.show()

In [12]: from pandas import *


ys = [[0,1,2,3,4], [4,3,2,1,0]]
x_ax = [0,1,2,3,4]
# subplots
#use of a for loop
for y_ax in ys:
ts = Series(y_ax, index=x_ax)
ts.plot(kind=bar, figsize=(15,5))
plt.show()

In [14]: import pandas as pd


import matplotlib.pyplot as plt
%matplotlib inline
ys = [[0,1,2,3,4],[4,3,2,1,0]]
x_ax = [0,1,2,3,4]
fig, axs = plt.subplots(ncols=2, figsize=(10, 4))
for i, y_ax in enumerate(ys):
pd.Series(y_ax, index=x_ax).plot(kind=bar, ax=axs[i])
axs[i].set_title(Plot number {}.format(i+1))

In [ ]: #EXERCISE: Can you use subplots to compare how the y = x**2

You might also like