1 * Script |
1 * Script |
2 |
2 |
3 *Hello and welcome to the tutorial on Basic Plotting using Python. |
3 *Hello and welcome to the tutorial on Basic Plotting using Python. |
4 |
4 |
5 *The intended audience for this tutorial are Engineering, mathematics and science teachers and students |
5 *The intended audience for this tutorial are Engineering, mathematics and science teachers and students |
6 |
|
7 *The goals are to |
|
8 help one use Python as a basic plotting tool. |
|
9 |
6 |
10 *In this tutorial, we will cover the basics of the Plotting features available in Python. |
7 *In this tutorial, we will cover the basics of the Plotting features available in Python. |
11 For this we shall use Ipython and pylab. |
8 For this we shall use Ipython and pylab. |
12 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. |
9 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. |
13 Pylab is python library which provides plotting functionality. |
10 Pylab is python library which provides plotting functionality. |
41 oops I made a mistake . As you can see I made the mistake of not writing command correctly |
38 oops I made a mistake . As you can see I made the mistake of not writing command correctly |
42 and Ipython changed the prompt . To get the old prompt back type crtl-c |
39 and Ipython changed the prompt . To get the old prompt back type crtl-c |
43 |
40 |
44 In []: x = linspace(0, 2*pi, 50) |
41 In []: x = linspace(0, 2*pi, 50) |
45 |
42 |
|
43 *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 |
|
44 |
|
45 |
|
46 *To know more about any function, example for the 'linspace' function you can type ? after it . |
|
47 |
|
48 In []: linspace? |
|
49 |
|
50 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, and down arrows keys. |
|
51 At any time you want to come out of the help use 'q' key. |
|
52 See how easy it is to get help in IPython. |
46 |
53 |
47 To obtain the plot we use, |
54 To obtain the plot we use, |
48 In []: plot(x, sin(x)) |
55 In []: plot(x, sin(x)) |
49 *** |
56 *** |
50 As you can see a plot has appeared on the screen. |
57 As you can see a plot has appeared on the screen. |
51 *** |
58 *** |
52 |
59 |
53 The plot has the default color and line properties. |
60 The plot has the default color and line properties. |
54 |
|
55 *To know more about any function, example for the 'linspace' function you can type ? after it . |
|
56 |
|
57 In []: linspace? |
|
58 |
|
59 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, and down arrows keys. |
|
60 At any time you want to come out of the help use 'q' key. |
|
61 See how easy it is to get help in IPython. |
|
62 |
|
63 *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 |
|
64 |
|
65 |
61 |
66 In this case we have used two commands |
62 In this case we have used two commands |
67 'pi' and 'sin' these come from 'pylab' library called using -pylab. |
63 'pi' and 'sin' these come from 'pylab' library called using -pylab. |
68 |
64 |
69 *Now that we have a basic plot, we can label and title the plot. |
65 *Now that we have a basic plot, we can label and title the plot. |