1 * Script |
1 * Script |
2 ********** |
2 ********** |
3 Some greeting-- Hi or Hello or Welcome - would be polite to start with |
3 Some greeting-- Hi or Hello or Welcome - would be polite to start with |
4 ********** |
4 ********** |
5 |
5 |
6 *Hello and welcome to this tutorial on Basic Plotting using Python in a series of tutorials on Python for Scientific Computing .This tutorial is created by the FOSSEE team , IIT Bombay . |
6 *Hello and welcome to the tutorial on Basic Plotting using Python. This is the first tutorial in a series of tutorials on Python for Scientific Computing. This tutorial is created by the FOSSEE team, IIT Bombay . |
7 |
7 |
8 *The intended audience for this tutorial are Engineering , mathematics and science teachers and students |
8 *The intended audience for this tutorial are Engineering, mathematics and science teachers and students |
9 |
9 |
10 *The goals are to |
10 *The goals are to |
11 help one use Python as a basic plotting tool. |
11 help one use Python as a basic plotting tool. |
12 and understand python as a scripting language. |
12 and understand python as a scripting language. |
13 |
13 |
14 |
14 |
15 *In this tutorial, we will cover the basics of the Plotting features available in Python. |
15 *In this tutorial, we will cover the basics of the Plotting features available in Python. |
16 For this we shall use Ipython and pylab. |
16 For this we shall use Ipython and pylab. |
17 Ipython is An Enhanced Interactive Python interpreter. It provides additional features like tab completion,easier access to help , and many other useful features. |
17 Ipython is An Enhanced Interactive Python interpreter. It provides additional features like tab completion,easier access to help , and many other useful features which are not present in the vanilla Python interpreter. |
18 Pylab is python library which provides plotting functionality. |
18 Pylab is python library which provides plotting functionality. |
19 |
19 |
20 I am assuming that you have both Ipython and Pylab installed on your system . |
20 I am assuming that you have both Ipython and Pylab installed on your system . |
21 |
21 |
22 *On your terminal type in the command Ipython -pylab |
22 *On your terminal type in the command Ipython -pylab |
23 $ ipython -pylab |
23 $ ipython -pylab |
24 press RETURN |
24 press RETURN |
25 |
25 |
26 We will first start with the absolute basic i.e how to print hello world |
26 We will first start with the absolute basic, that is how to print hello world |
27 |
27 |
28 In []: print 'hello world' |
28 In []: print 'hello world' |
29 |
29 |
30 Voila we have got hello world output |
30 Voila we have got hello world as the output |
31 |
31 |
32 To exit ipython type Ctrl-D . It will ask if you wish to exit ipython . |
32 To exit ipython press Ctrl-D. |
33 |
33 |
34 *Now we will get back to plotting . |
34 *Now we will get back to plotting. |
35 |
35 |
36 type again : |
36 type again : |
37 $ ipython -pylab |
37 $ ipython -pylab |
38 press RETURN |
38 press RETURN |
39 |
39 |
59 |
59 |
60 *To know more about any function, example for the 'linspace' function you can type ? after it . |
60 *To know more about any function, example for the 'linspace' function you can type ? after it . |
61 |
61 |
62 In []: linspace? |
62 In []: linspace? |
63 |
63 |
64 It shows documentation related to linspace function. 'help' talks in detail about arguments to be passed, return values, some examples on usage. You can scroll the help using up , down and pageup and pagedown arrows and q for quitting . See how easy to get help in python . |
64 It shows documentation related to linspace function. 'help' talks in detail about arguments to be passed, return values, some examples on usage. You can scroll the help using up , down arrows , pageup and pagedown keys . |
|
65 At any time you want to come out of the help use q key . |
|
66 See how easy it is to get help in python . |
65 |
67 |
66 *As you can see linspace can take three parameters start, stop, and num and returns num evenly space points . You can scroll through the help to know more about the function |
68 *As you can see linspace can take three parameters start, stop, and num and returns num evenly space points . You can scroll through the help to know more about the function |
67 |
69 |
68 |
70 |
69 In this case we have used two commands |
71 In this case we have used two commands |
87 |
89 |
88 To go to previous command, we can use 'UP Arrow key' and 'DOWN' will take us (in reverse order)/back. |
90 To go to previous command, we can use 'UP Arrow key' and 'DOWN' will take us (in reverse order)/back. |
89 |
91 |
90 We can modify previous command to specify the location of the legend, by passing an additional argument to the function. |
92 We can modify previous command to specify the location of the legend, by passing an additional argument to the function. |
91 #Ask madhu how to describe the feature here. |
93 #Ask madhu how to describe the feature here. |
|
94 Once you start editing a previous command and then you try to use 'Up arrow key ' you can get commands that are only similar to the command you are editing . But if you move your cursor to the beginning of the line you can get all the previous commands using up and down arrow keys . |
92 In []: legend(['sin(x)'], loc = 'center') |
95 In []: legend(['sin(x)'], loc = 'center') |
93 |
96 |
94 Note that once |
97 Note that once |
95 other positions which can be tried are |
98 other positions which can be tried are |
96 'best' |
99 'best' |