Created
March 17, 2012 08:48
-
-
Save xuhdev/2056798 to your computer and use it in GitHub Desktop.
Use matplotlib to plot scatter graph for ascii data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
# plot scatter graph for ascii data | |
# | |
# The file is read from stdin. | |
# | |
# data format: | |
# | |
# x0 y0 | |
# x1 y1 | |
# .. | |
# xn yn | |
# | |
# example file: | |
# | |
# -3 9 | |
# -2 4 | |
# -1 1 | |
# 0 0 | |
# 1 1 | |
# 2 4 | |
# 3 9 | |
# | |
import matplotlib.pyplot as plt | |
import sys | |
xes = [] | |
yes = [] | |
for line in sys.stdin.readlines(): | |
splited_line = line.split() | |
x = float(splited_line[0]) | |
y = float(splited_line[1]) | |
xes.append(x) | |
yes.append(y) | |
plt.plot(xes, yes, 'ro') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment