# the following lines are needed to import the content of different
# software packets (indeed, only the first one is strictly needed for the
# purpose of the present script, the following ones will be needed in the 
# next implementations)
import pylab
import numpy
from scipy.optimize import curve_fit

# this is the command which extract the data from the columns in the text file
# the "unpack" instruction is required, don't forget it
# note that the file is stored in some directory of my own computer
R,I,dR,dI=pylab.loadtxt('D:/stash/dida14_15/lab2_14_15/fitte_ohm/data.txt',unpack=True)

# lines needed to increase the font size (to improve readibility), to put the 
# correct labels on the axes, to make minor ticks to appear, to have the logarithmic 
# representation
pylab.rc('font',size=16)
pylab.xlabel('R  [kohm]')
pylab.ylabel('I  [mA]')
pylab.xscale('log'); pylab.yscale('log')

# draw the plot with errorbars: NOTE THE UGLY SYNTAX FOR INDICATING ERRORS 
# IN THE AXES (THE VERTICAL ERROR BAR COLUMN COMES BEFORE THE HORIZONTAL ONE!)
# the linestyle command says that no line is needed, the marker is a circle,
# the color is black
pylab.errorbar(R,I,dI,dR,linestyle = '', color = 'black', marker = 'o')

# save the plot as a pdf file somewhere (in my own directories!)
pylab.savefig('D:/stash/dida14_15/lab2_14_15/fitte_ohm/fig2.pdf')

# show the plot on screen
pylab.show()

