Seite - 19 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 19 -
Text der Seite - 19 -
1.5 MoreBasicConcepts 19
Fig.1.2 Generatedplot for theheightsof familymembers fromtwo families
from numpy import zeros
import matplotlib.pyplot as plt
h = zeros(4)
h[0] = 1.60; h[1] = 1.85; h[2] = 1.75; h[3] = 1.80
H = zeros(4)
H[0] = 0.50; H[1] = 0.70; H[2] = 1.90; H[3] = 1.75
family_member_no = zeros(4)
family_member_no[0] = 0; family_member_no[1] = 1
family_member_no[2] = 2; family_member_no[3] = 3
plt.plot(family_member_no, h, family_member_no, H)
plt.xlabel(’Family member number’)
plt.ylabel(’Height (m)’)
plt.show()
Running theprogramgives theplot shown inFigure1.2.
Alternatively, the twocurvescouldhavebeenplotted in the sameplot byuseof
twoplot commands,whichgivesmore freedomas tohowthecurvesappear. Todo
this, youcouldplot thefirst curveby
plt.plot(family_member_no, h)
plt.hold(’on’)
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2016
- Sprache
- englisch
- Lizenz
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 248
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik