Ebook Introduction to computation and programming using Python: Part 2
➤ Gửi thông báo lỗi ⚠️ Báo cáo tài liệu vi phạmNội dung chi tiết: Ebook Introduction to computation and programming using Python: Part 2
Ebook Introduction to computation and programming using Python: Part 2
11 PLOTTING AND MORE ABOUT CLASSESOften text is the best way to communicate information, but sometimes there is a lot of truth to the Chinese proverb. Ebook Introduction to computation and programming using Python: Part 2 .(“A picture's meaningcan express ten thousand words”). Yet most programs rely on textual output to communicate with their users. Why? Because in many programming languages presenting Visual data IS too hard. Fortunately. It IS simple to do in Python.11.1 Plotting Using PyLabPyLab is a Python standa Ebook Introduction to computation and programming using Python: Part 2 rd library module that provides many of the facilities of MATLAB, “a high-level technical computing language and interactive environment for algorithmEbook Introduction to computation and programming using Python: Part 2
development, data visualization, data analysis, and numeric computation.*37 Later in the book, we will look at some of the more advanced features of 11 PLOTTING AND MORE ABOUT CLASSESOften text is the best way to communicate information, but sometimes there is a lot of truth to the Chinese proverb. Ebook Introduction to computation and programming using Python: Part 2 ceforge.net/users/index.htinl. There are also a number of Web sites that provide excellent tutorials. We will not try to provide a user’s guide or a complete tutorial here. Instead, in this chapter we will merely proride a few example plots and explain the code that generated them. Other examples ap Ebook Introduction to computation and programming using Python: Part 2 pear in later chapters.Let’s start with a simple example that uses pylab.plot to produce two plots. Executingimport pylabpylab.figure(l) ^create figurEbook Introduction to computation and programming using Python: Part 2
e 1 pylab.plot([l,2,3,4], [1,7,3,5]) #draw on figure 1 pylab.showf) #show figure on screenwill cause a window to appear on your computer monitor. Its 11 PLOTTING AND MORE ABOUT CLASSESOften text is the best way to communicate information, but sometimes there is a lot of truth to the Chinese proverb. Ebook Introduction to computation and programming using Python: Part 2 /matlab/description 1 html?8_cid"ML_b 1008_d«8intro142Chủpĩtr ì 1. Plotting and Síộrr A'nut ClatUỉThe bar at the top contains the name of the window, in this case “Figure 1.”The middle section of the window contains the plot generated by the invocation of pylab.plot. The two parameters of pylab.plot Ebook Introduction to computation and programming using Python: Part 2 must be sequences of the same length. The first specifies the x-coordinates of the points to be plotted, and the second specifies the y-coordinates.Ebook Introduction to computation and programming using Python: Part 2
Together, they provide a sequence of fourEbook Introduction to computation and programming using Python: Part 2
he appearance of the plot in the window. The next four buttons are used for panning and zooming. And the button on the left is used to restore the fig11 PLOTTING AND MORE ABOUT CLASSESOften text is the best way to communicate information, but sometimes there is a lot of truth to the Chinese proverb. Ebook Introduction to computation and programming using Python: Part 2 se flies can have any name you like, but they Will all have the file extension .png. The file extension .png indicates that the file is in the Portable Networks Graphics format. This is a public domain standard for representing images.58 In some operating systems, pylab. showQ causes die process run Ebook Introduction to computation and programming using Python: Part 2 ning Python to be suspended until the figure is closed (by clicking on the round red button at die upper lefthand corner of the windowl. Tins is unforEbook Introduction to computation and programming using Python: Part 2
tunate. The usual workaround is to ensure that pylab. sliow() is the last line of code to be executed.w For those of you too young to know, the icon r11 PLOTTING AND MORE ABOUT CLASSESOften text is the best way to communicate information, but sometimes there is a lot of truth to the Chinese proverb. Ebook Introduction to computation and programming using Python: Part 2 r floppy disks, they actually were floppy. The original IBM PC had a single 160Kbyte 5.5-inch floppy disk drive. For most of the 1970s and 1980s. floppy disks were the primary' storage device for personal computers. The transition to rigid enclosures (as represented in the icon that launched this di Ebook Introduction to computation and programming using Python: Part 2 gression) started in the mid-1980s (with the Macintosh), which didn’t stop people from continuing to call them floppy disks.143Cbapĩtr ỉ ỉ. PhĩíÌNỊ anEbook Introduction to computation and programming using Python: Part 2
d Mộrr AbwEbook Introduction to computation and programming using Python: Part 2
ie.pngPyLab has a notion of "current figure.” Executing pylab.figure(x) sets the current figure to the figure numbered X. Subsequently executed calls 11 PLOTTING AND MORE ABOUT CLASSESOften text is the best way to communicate information, but sometimes there is a lot of truth to the Chinese proverb. Ebook Introduction to computation and programming using Python: Part 2 e figure Addie.png was the second figure created.Let’s look at another example, 'rhe codeprincipal - 10000 ^initial investmentinterestRate - 0.0511 PLOTTING AND MORE ABOUT CLASSESOften text is the best way to communicate information, but sometimes there is a lot of truth to the Chinese proverb.Gọi ngay
Chat zalo
Facebook