KHO THƯ VIỆN 🔎

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ạm

Loại tài liệu:     PDF
Số trang:         158 Trang
Tài liệu:           ✅  ĐÃ ĐƯỢC PHÊ DUYỆT
 













Nộ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 algorithm

Ebook 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 c

omplete 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 figur

Ebook 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 four coordinate pairs, [(1,1), (2,7), (3,3), (4,5)]. These are plotted in order. As each point IS plotted,

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 at line were not present, the figure would still have been produced, but it would not have been displayed. This is not as silly as it at first sounds,

since one might well choose to write a figure directly to a file, as we Will do later, rather than display it on the screen.The bar at the bottom of Ebook Introduction to computation and programming using Python: Part 2

the window contains a number of push buttons. The rightmost button is used to write the plot to a file.The next button to the left is used to adjust t

Ebook 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 fig

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 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 Portabl

e 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 unfor

Ebook 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 r

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 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. flop

py 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Ị an

Ebook Introduction to computation and programming using Python: Part 2

d Mộrr Abw

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 ,6,10,3|) #draw again on figure 1 pylab.savefig(’Figure-lane*) tfsave figure 1produces and saves to flics named Figure- Jane.png and F igui e-Add ie .

ptiij the two plots below.Observe dial the last call to py lab.p lot is passed only one argument. This argument supplies the y values. The correspondi Ebook Introduction to computation and programming using Python: Part 2

ng X values default to range( lent IS, 6, 10, 31)). which is why they range from 0 to 3 in this case.Contents of Figure-Jane.pngContents of Figure-Add

Ebook 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.05

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.

Gọi ngay
Chat zalo
Facebook