matplotlib - Regarding plotting a graph in python using matplolib from the input in text file -


i have written python code generates output in form of text file. numbers in result small(of order of 10^-120) , written in scientific notation in form 1e-120 in output file. wish plot graph using output in text file. how plot graph?

the output in form 1 '\t' 2 stored in text file. wish plot simple x y plot between 2 variables.

i asking here since not find related anywhere , new python. thanks.

assuming values x -> y mapping (e.g. 1d function), plotting these values simple. if have x values in iterable (i.e. list or array or can iterate over) x , y values in iterable y, need import pyplot , do

import matplotlib.pyplot plt plt.plot(x, y) plt.show() 

the fact values small not problem. however, sake of presentation might want rescale them multiplying values number, 1e120.

edit: see right need import data. easiest way numpy.loadtxt. assuming data written in file in matrix format (one column x, 1 y), data in same format.

import numpy np import matplotlib.pyplot plt data = np.loadtxt('path/to/file') x,y = data[:, 0], data[:,1] plt.plot(x,y) plt.show() 

Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -