import matplotlib.pyplot as plt
import numpy as np
import pylab as py
%matplotlib inline
x = np.arange(40) #Datensaetze erzeugen
y1 = np.sqrt(x)
y2 = 0.01*x**2
plt.plot(x, y1)
plt.show()
plt.plot(x, y1, marker='o')
plt.show()
# Marker:
# + Plus Sign
# . Dot
# o Circle
# * Star
# p Pentagon
# s Square
# x X Character
# D Diamond
# h Hexagon
# ^ Triangle '''
plt.plot(x, y1, marker='.', color='r')
plt.show()
# color:
# r Red
# b Blue
# g Green
# c Cyan
# m Magenta
# y Yellow
# k Black
# w White
plt.plot(x, y1, marker='+', linestyle='None', color='r')
plt.show()
# linestyle:
# – Solid Line
# -- Dashed Line
# : Dotted Line
# -. Dash-Dotted Line
# None No Connecting Lines
plt.plot(x, y1, marker='+', linestyle='None', color='b',label='Wurzel')
plt.plot(x, y2, marker='.', linestyle='None', color='g',label='Quadrat')
plt.legend()
plt.xlabel('x / unit')
plt.ylabel('y / unit')
plt.title('Basic Functions')
plt.axis([0, 40, 0, 8.5]) #x_start, x_stop, y_start, y_stop
#pl.xlim(0, 40) x-Bereich
#pl.ylim(0, 8.5) y-Bereich
#Diagramm speichern:
#Supported formats: emf, eps, pdf, png, jpg, ps, raw, rgba, svg, svgz
plt.savefig('figures/myfunction.pdf', format='PDF')
plt.show()
plt.plot(x, y1, marker='+', linestyle='None', color='b',label='$\sqrt{x}$') #'$ mein Latex $'
plt.plot(x, y2, marker='.', linestyle='None', color='g',label='$0.01 x^2$')
plt.legend()
plt.plot(x, y1, marker='+', linestyle='None', color='b',label='$\sqrt{x}$')
plt.plot(x, y2, marker='.', linestyle='None', color='g',label='$0.01 x^2$')
plt.legend(loc=0) #loc=0 links oben, #loc=1 (default) rechts oben, #loc=2 rechts unten, #loc=3 links unten
plt.plot(x, y1, marker='+', linestyle='None', color='b',label='$\sqrt{x}$')
plt.plot(x, y2, marker='.', linestyle='None', color='g',label='$0.01 x^2$')
plt.legend(loc='best') #findet die beste Position für die Legende
plt.plot(x, y1, marker='+', linestyle='None', color='b',label='$\sqrt{x}$')
plt.plot(x, y2, marker='.', linestyle='None', color='g',label='$0.01 x^2$')
plt.legend(bbox_to_anchor=(1.28, 1.02)) # Legende frei platzieren: bbox_to_anchor=(x,y)
plt.figure(figsize=(8,6)) #Diagrammgroesse
plt.plot(x, y1, marker='o',markersize=5, linestyle='None', color='b',label=r'$\sqrt{x}$') #Markergroesse: markersize=
plt.plot(x, y2, marker='*',markersize=8, linestyle='None', color='g',label=r'$\frac{x^2}{100}$')
plt.legend(loc='best',prop={'size':20}) #Legendengroesse
plt.rc('figure', figsize=(9,6))
plt.rc('axes', grid=True,labelsize=16)
plt.rc('xtick', labelsize=16)
plt.rc('ytick', labelsize=16)
plt.rc('lines', markersize=8, linestyle='None')
plt.rc('legend',markerscale=1.5, loc='best', fontsize=20, shadow=True, framealpha=1)
plt.plot(x, y1, marker='+', color='b',label='$\sqrt{x}$')
plt.plot(x, y2, marker='*', color='g',label='$0.01 x^2$')
plt.xlabel('x / unit')
plt.ylabel('y / unit')
plt.legend()
plt.rcdefaults() #Formatierung auf default zuruecksetzen
%matplotlib inline
t, N = py.loadtxt('data/zerfall.dat', unpack=True) #Messwerte importieren
plt.plot(t,N,linestyle='None',marker='o')
plt.xlabel('Zeit / min')
plt.ylabel('counts / N')
plt.title('Radioaktiver Zerfall')
plt.yscale('log')
y_err=np.sqrt(N)
plt.errorbar(t, N, yerr=y_err, fmt='.') #plt.errorbar(x, y, yerr=None, xerr=None, fmt='',...
plt.xlabel('Zeit / min')
plt.ylabel('counts / N')
plt.title('Radioaktiver Zerfall')
plt.yscale('log')