In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
For Jupyter Notebooks Only
In [2]:
%matplotlib inline
For other IDES use plt.show() after your plot commands
In [3]:
x = np.arange(0, 10)
In [4]:
y = x ** 2
In [5]:
x
Out[5]:
In [6]:
y
Out[6]:
In [7]:
plt.plot(x, y)
Out[7]:
In [8]:
# Visualizing the data with a specific marker
plt.plot(x, y, marker = '*')
Out[8]:
In [9]:
# Visualizing the data with a marker and linestyle
plt.plot(x, y, 'r--')
Out[9]:
In [10]:
# Visualizing the data with a marker and linestyle (with arguments description)
plt.plot(x, y, color = 'r', linestyle = '--')
Out[10]:
In [11]:
# Zooming, axis naming and title
plt.plot(x, y, 'r--')
plt.xlim(2, 4)
plt.ylim(10, 20)
plt.title("Zoomed")
plt.xlabel("X Axis")
plt.ylabel("Y Axis")
Out[11]:
In [12]:
mat = np.arange(0, 100).reshape(10, 10)
In [13]:
# Show image from an array
plt.imshow(mat)
Out[13]:
In [14]:
mat = np.random.randint(0, 100, (10, 10))
In [15]:
plt.imshow(mat)
Out[15]:
In [16]:
# Changing color map
plt.imshow(mat, cmap = 'coolwarm')
plt.colorbar()
Out[16]:
In [17]:
df = pd.read_csv('salaries.csv')
In [18]:
df
Out[18]:
In [19]:
# Scatter plot
df.plot(x = 'Salary',
y = 'Age',
kind = 'scatter')
Out[19]:
In [20]:
# Histogram
df.plot(x = 'Salary',
kind = 'hist')
Out[20]: