0

I have *.txt files and now i want to take the data content and plot it in a Graph. But the *.png have to be new create.

I have no clue how to create a png file and no clue about how to read the data content from a txt and put it in the png file that´s in the end a diagram.

any suggestions?

3
  • What do you mean by "put it in" the PNG file? How should the PNG reflect the text?
    – user647772
    Jul 30, 2012 at 8:29
  • Do you mean plot the data in a graph in png format? What have you tried so far?
    – Levon
    Jul 30, 2012 at 8:31
  • yea thats what i mean. i have tried nothing because i have totaly no clue how to do it.
    – zeromancer
    Jul 30, 2012 at 8:39

2 Answers 2

4

You need the packages numpy and matplotlib

import nunmpy as np
import matplotlib.pyplot as plt

data=np.loadtxt("YourFileName.txt", dtype="YourDataType", delimiter=",")
plt.plot(data)
plt.show()    #if you want to see the plot
plt.savefig("PngFile.png")

Done.

1
  • perfect, thats what i was looking for
    – zeromancer
    Jul 30, 2012 at 8:58
0

If you need to plot a graph like diagram from your data, consider using graphviz.

If you have an ascii art diagram that you want to convert into a .png, consider using ditaa.

If you want to create an arbitrary png using some data, consider using PIL.

2
  • I want to plot from txt to png but i need to use python
    – zeromancer
    Jul 30, 2012 at 8:55
  • You've not mentioned what you have in your .txt file. As I mentioned, the tool and method depends on what and how you want to plot your data. A screenshot is different from a histogram. Jul 30, 2012 at 8:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.