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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -