Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active December 19, 2017 00:30
Show Gist options
  • Select an option

  • Save BlogBlocks/fa114883bc30db0a6bd24693e8b32859 to your computer and use it in GitHub Desktop.

Select an option

Save BlogBlocks/fa114883bc30db0a6bd24693e8b32859 to your computer and use it in GitHub Desktop.
import pylab
Text = """315.42,
316.31,
316.5,
317.56,
318.13,
318,
316.39,
314.65,
313.68,
313.18,
314.66,
315.43,
316.27,
316.81,
317.42,
318.87,
319.87,
319.43,
318.01,
315.74
"""
filename = "test.data"
# Create file Test.data from the string ' Text ' above.
CreateTextData = open(filename, "w+")
# Convert Text string - write will note deal with floats
Text = str(Text)
# Enter Text into the test.data file
CreateTextData.write(Text)
# Create an empty list
data=[]
# Open your newly created test.data
# Reading it as lines
lines = open(filename).readlines()
# Read a line from the Lines
for line in lines:
#Remove the tailing ( rstrip() : ,\n
line = line.rstrip(",\n")
#append the data list with the line
data.append(line)
# Prepare to draw plot
pylab.figure(1)
# The range must match the lines of data
x = range(20)
# Plot the data - color "g" - green
pylab.plot(x,data,"g")
# Show the plot
pylab.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment