Skip to content

Instantly share code, notes, and snippets.

View fishnsotong's full-sized avatar

Wayne Yeo fishnsotong

View GitHub Profile
@fishnsotong
fishnsotong / plotgraph.py
Last active January 6, 2017 01:11
Making a line plot in python by importing data from a csv file.
import numpy as np
import matplotlib.pyplot as plt
# importing data from csv file
xs, ys, zs = np.loadtxt("data.txt", unpack=True, delimiter=",", dtype=float)
# plotting
plt.plot(xs, ys, "b-", label="line one") # blue line, label displayed in legend
plt.plot(xs, zs, "r-", label="line two") # red line, for scatter plot replace with "ro"