Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - 27 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 27 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - 27 -

Bild der Seite - 27 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 27 -

1.6 Plotting,PrintingandInputData 27 Fig. 1.4 Ball trajectory and functionsf(t)= t2 andg(t)= et as two plots inone figure Note that,whendealingwith subplots, someoverlappingofsubplotsmayoccur. Usually, this is solved nicely by inserting the following line (as at the end of our code), plt.tight_layout() Thiswill causesubplotparameters tobeautomaticallyadjusted,so that thesubplots fit in to thefigurearea. Theplotgeneratedby thecode is shownin Fig.1.4. MakingaHardcopy Savinga figure to file is achievedby plt.savefig(’some_plot.png’) # PNG format plt.savefig(’some_plot.pdf’) # PDF format plt.savefig(’some_plot.jpg’) # JPG format plt.savefig(’some_plot.eps’) # Encanspulated PostScript format 1.6.2 Printing:TheStringFormatMethod We havepreviouslyseen that print(y) will print thevalueof thevariabley. Inanequallysimple way, the line print(’This is some text’) will print This is some text (note the enclosing single quotes in the call to print).Often,however, it is of interest to print variablevalues togetherwith some descriptive text. As shown below, such printing can be done nicely and controlled in Python, since the language basically allows text and numbers to be mixed and formatted inanywayyouneed.
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python 3.6
Band
Second Edition
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2020
Sprache
englisch
Lizenz
CC BY 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
356
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python