Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Page - 27 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

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

Image of the Page - 27 -

Image of the Page - 27 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Text of the Page - 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.
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python 3.6
Volume
Second Edition
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2020
Language
English
License
CC BY 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
356
Keywords
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Category
Informatik
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python