author | amit@thunder |
Mon, 05 Apr 2010 19:27:32 +0530 | |
changeset 16 | cdcad776b360 |
parent 13 | 847f9aefa7d4 |
child 17 | 4ec2ba3d96f5 |
permissions | -rw-r--r-- |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
1 |
* Script |
5 | 2 |
********** |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
3 |
Some greeting-- Hi or Hello or Welcome - would be polite to start with |
5 | 4 |
********** |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
5 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
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 . |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
7 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
8 |
*The intended audience for this tutorial are Engineering , mathematics and science teachers and students |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
9 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
10 |
*The goals are to |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
11 |
help one use Python as a basic plotting tool. |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
12 |
and understand python as a scripting language. |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
13 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
14 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
15 |
*In this tutorial, we will cover the basics of the Plotting features available in Python. |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
16 |
For this we shall use Ipython and pylab. |
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
17 |
Ipython is An Enhanced Interactive Python interpreter. It provides additional features like tab completion,easier access to help , and many other useful features. |
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
18 |
Pylab is python library which provides plotting functionality. |
4
4dee50d4804b
Added changes to array.org file and basic plotting.
Shantanu <shantanu@fossee.in>
parents:
0
diff
changeset
|
19 |
|
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
20 |
I am assuming that you have both Ipython and Pylab installed on your system . |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
21 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
22 |
*On your terminal type in the command Ipython -pylab |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
23 |
$ ipython -pylab |
4
4dee50d4804b
Added changes to array.org file and basic plotting.
Shantanu <shantanu@fossee.in>
parents:
0
diff
changeset
|
24 |
press RETURN |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
25 |
|
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
26 |
We will first start with the absolute basic i.e how to print hello world |
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
27 |
|
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
28 |
In []: print 'hello world' |
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
29 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
30 |
Voila we have got hello world output |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
31 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
32 |
To exit ipython type Ctrl-D . It will ask if you wish to exit ipython . |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
33 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
34 |
*Now we will get back to plotting . |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
35 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
36 |
type again : |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
37 |
$ ipython -pylab |
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
38 |
press RETURN |
5 | 39 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
40 |
First, we will create a sequence of equally spaced points starting from 0 to 2*pi , we will use function linspace for that |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
41 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
42 |
Type: |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
43 |
In []: x = lins<Tab> This is an Ipython feature that will auto-suggest the word |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
44 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
45 |
In [] x=linspace( |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
46 |
oops I made a mistake . As you can see I made the mistake of not writing command correctly |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
47 |
and Ipython changed the prompt . To get the old prompt back type crtl-c |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
48 |
|
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
49 |
In []: x = linspace(0, 2*pi, 50) |
5 | 50 |
|
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
51 |
|
5 | 52 |
To obtain the plot we say, |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
53 |
In []: plot(x, sin(x)) |
5 | 54 |
*** |
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
55 |
As you can see a plot has appeared on the screen. |
5 | 56 |
*** |
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
57 |
|
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
58 |
The plot has the default color and line properties. |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
59 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
60 |
*To know more about any function, example for the 'linspace' function you can type ? after it . |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
61 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
62 |
In []: linspace? |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
63 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
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 . |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
65 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
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 |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
67 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
68 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
69 |
In this case we have used two commands |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
70 |
'pi' and 'sin' these come from 'pylab'library called using -pylab. |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
71 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
72 |
*Now that we have a basic plot, we can label and title the plot. |
5 | 73 |
In []: xla<TAB>bel('x') will add a label to the x-axis. Note that 'x' is enclosed in quotes. |
74 |
Similarly |
|
75 |
In []: ylabel('sin(x)') adds a label to the y-axis. |
|
76 |
To add a title to plot we simply use |
|
77 |
In []: tit<TAB>le('Sinusoid'). |
|
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
78 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
79 |
Hmm we also got the axis's nicely labeled and the plot titled but there is still a important detail left.That might leave a teacher seeing this unsatisfied , it lacks a legend. |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
80 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
81 |
Add a legend to the plot by typing |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
82 |
In []: legend(['sin(x)']) |
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
83 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
84 |
Ok what if I want the legend to be in the centre . It just requires us to define one extra parameter. |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
85 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
86 |
We have just typed legend command can we reuse it . Yes |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
87 |
|
5 | 88 |
To go to previous command, we can use 'UP Arrow key' and 'DOWN' will take us (in reverse order)/back. |
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
89 |
|
5 | 90 |
We can modify previous command to specify the location of the legend, by passing an additional argument to the function. |
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
91 |
#Ask madhu how to describe the feature here. |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
92 |
In []: legend(['sin(x)'], loc = 'center') |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
93 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
94 |
Note that once |
5 | 95 |
other positions which can be tried are |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
96 |
'best' |
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
97 |
'right' |
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
98 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
99 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
100 |
Very often in mathematical plots we have define certain points abd there meaning also called annotating . We next look at how to annotate |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
101 |
In this case, let's add a comment at the point of origin. |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
102 |
In []: annotate('origin', xy=(0, 0)) |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
103 |
|
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
104 |
The first argument is the comment string and second one is the position for it. |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
105 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
106 |
Ok, what do I do with all this effort . I obviously have to save it . |
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
107 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
108 |
We save the plot by the function savefig |
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
109 |
In []: savefig('sin.png') saves the figure with the name 'sin.png' in the current directory. |
5 | 110 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
111 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
112 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
113 |
|
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
114 |
#other supported formats are: eps, ps, pdf etc. |
5 | 115 |
|
116 |
When we use plot again by default plots get overlaid. |
|
117 |
In []: plot(x, cos(x)) |
|
118 |
||
119 |
we update Y axis label |
|
120 |
In []: ylabel('f(x)') |
|
121 |
||
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
122 |
Now in these situations with overlaid graphs, legend becomes absolutely essential. To add multiple legends, we pass the strings within quotes separated by commas and enclosed within square brackets as shown. |
5 | 123 |
|
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
124 |
In []: legend( [ 'sin(x)' , 'cos(x)'] ) |
5 | 125 |
|
126 |
In []: clf() |
|
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
127 |
clears the plot area and starts afresh. |
5 | 128 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
129 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
130 |
|
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
131 |
*In case we want to create multiple plots rather than overlaid plots, we use 'figure' function. |
5 | 132 |
The figure command is used to open a plain figure window without any plot. |
133 |
In []: figure(1) |
|
134 |
||
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
135 |
We will use plot() plot again to plot a sin curve on figure(1) |
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
136 |
In []: plot(x, sin(x)) |
5 | 137 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
138 |
to creates a new plain figure window without any plot type: |
5 | 139 |
In []: figure(2) |
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
140 |
figure() is also used to shift the focus between multiple windows. |
5 | 141 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
142 |
Any command issued henceforth applies to this window only so typing |
5 | 143 |
In []: plot(x, cos(x)) |
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
144 |
plots cos curve on second window now. |
5 | 145 |
The previous plot window remains unchanged to these commands. |
146 |
||
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
147 |
|
5 | 148 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
149 |
calling function figure using argument 1 shifts the focus back to figure(1). |
5 | 150 |
In []: figure(1) |
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
151 |
|
5 | 152 |
title() sets the title of figure(1) |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
153 |
In []: title('sin(x)') |
5 | 154 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
155 |
Now we save the plot of figure(1) by typing |
5 | 156 |
In []: savefig('sine.png') |
157 |
||
158 |
close() closes figure(1). Now there is just one figure that is open and hence |
|
159 |
the focus is automatically shifted to figure(2). |
|
160 |
In []: close() |
|
161 |
||
162 |
close() now closes the figure(2). |
|
163 |
In []: close() |
|
164 |
||
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
165 |
The plot command takes the parameters such as 'g' which generates the plot in green color. |
5 | 166 |
|
167 |
Passing the linewidth=2 option to plot, generates the plot with linewidth of two units. |
|
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
168 |
Use Up arrow to get to the previous commands |
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
169 |
In []: plot(x, sin(x), 'g', linewidth=2) and add arguments |
5 | 170 |
|
171 |
In []: clf() |
|
172 |
||
9
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
173 |
In order to plot points you may pass '.' as a parameter to plot |
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
174 |
In []: plot(x, sin(x), '.') |
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
175 |
|
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
176 |
In []: clf() |
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
177 |
|
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
178 |
In order to plot filled circles in black color you can pass 'ko' parameter to plot |
538f59bb598c
Minor edits to basic-plot.txt.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
179 |
In []: plot(x, cos(x), 'ko') |
5 | 180 |
|
181 |
In []: clf() |
|
182 |
||
183 |
A plot using dashed lines can be generated by passing the '--' parameter |
|
13
847f9aefa7d4
Changes in the end some problem with continuity of commands . Fixed it .
amit@thunder
parents:
11
diff
changeset
|
184 |
In []: plot(x, sin(x), '--') |
5 | 185 |
|
16
cdcad776b360
Changed according Prabhu sirs comments on the script
amit@thunder
parents:
13
diff
changeset
|
186 |
You may look at more options related to colors and type of lines using plot?(question mark) |
5 | 187 |
|
188 |
In []: clf() |
|
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
189 |
|
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
190 |
and finally to close the plot |
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
191 |
In []: close() |
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
192 |
|
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
193 |
|
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
194 |
|
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
195 |
|
0
67604aed10e0
Initialization and scripts for first two sessions.
shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
196 |
**************** |
11
eafc653206d8
Made changes to incorporate suggestions for adding info about ipython and pointers from spoken tutorials workshop
amit@thunder
parents:
9
diff
changeset
|
197 |
This brings us to the end of this tutorial. Thank you for attending this first tutorial on Python for Scientific Computing |
5 | 198 |
**************** |