26 |
26 |
27 As you can see, the colour and thickness of line as decided by pylab. It would |
27 As you can see, the colour and thickness of line as decided by pylab. It would |
28 be nice if we could control these parameters in the plot. This is possible by |
28 be nice if we could control these parameters in the plot. This is possible by |
29 passing additional arguments to the plot command. |
29 passing additional arguments to the plot command. |
30 |
30 |
|
31 .. #[[Anoop: I think it will be good to rephrase the sentence]] |
|
32 |
31 The second argument that we shall be passing is colour. We shall first clear |
33 The second argument that we shall be passing is colour. We shall first clear |
32 the figure and plot the same in red colour.Hence |
34 the figure and plot the same in red colour. Hence |
33 :: |
35 :: |
34 |
36 |
35 clf() |
37 clf() |
36 plot(x, sin(x), 'r') |
38 plot(x, sin(x), 'r') |
37 |
39 |
38 Plots the same curve but now in red colour. |
40 Plots the same curve but now in red colour. |
39 |
41 |
40 To alter the thickness of the line, we use the =linewidth= argument in the plot |
42 To alter the thickness of the line, we use the =linewidth= argument in the plot |
41 command.Hence |
43 command. Hence |
42 :: |
44 :: |
43 |
45 |
44 plot(x, cos(x), linewidth=2) |
46 plot(x, cos(x), linewidth=2) |
45 |
47 |
46 produces a plot with a thicker line. |
48 produces a plot with a thicker line. |
47 |
49 |
48 {{{ Show the plot and compare the sin and cos plots }}} |
50 .. #[[Anoop: I guess it will be good if you say that it affects the |
49 |
51 same plot, as you have not cleared the figure]] |
50 {{{ Pause here and try out the following exercises }}} |
52 |
|
53 {{{ Show the plot and compare the sine and cos plots }}} |
|
54 |
|
55 {{{ Pause here and try out the following exercises }}} |
|
56 |
|
57 .. #[[Anoop: is the above a context switch for the person who does the |
|
58 recording, other wise if it an instruction to the person viewing the |
|
59 video, then I guess the three braces can be removed.]] |
51 |
60 |
52 %% 1 %% Plot sin(x) in blue colour and with linewidth as 3 |
61 %% 1 %% Plot sin(x) in blue colour and with linewidth as 3 |
53 |
62 |
54 {{{ continue from paused state }}} |
63 {{{ continue from paused state }}} |
55 |
64 |
56 A combination of colour and linewidth would do the job for us. Hence |
65 A combination of colour and linewidth would do the job for us. Hence |
57 :: |
66 :: |
58 |
67 |
59 plot(x, sin(x), 'b', linewidth=3) |
68 plot(x, sin(x), 'b', linewidth=3) |
|
69 |
|
70 .. #[[Anoop: add clf()]] |
60 |
71 |
61 produces the required plot |
72 produces the required plot |
62 |
73 |
63 #[Nishanth]: I could not think of a SIMPLE recipe approach for introducing |
74 #[Nishanth]: I could not think of a SIMPLE recipe approach for introducing |
64 linestyle. Hence the naive approach. |
75 linestyle. Hence the naive approach. |
|
76 |
|
77 .. #[[Anoop: I guess the recipe is fine, but would be better if you |
|
78 add the problem statement rather than just saying "let's do a simple |
|
79 plot"]] |
65 |
80 |
66 Occasionally we would also want to alter the style of line. Sometimes all we |
81 Occasionally we would also want to alter the style of line. Sometimes all we |
67 want is just a bunch of points not joined. This is possible by passing the |
82 want is just a bunch of points not joined. This is possible by passing the |
68 linestyle argument along with or instead of the colour argument.Hence |
83 linestyle argument along with or instead of the colour argument.Hence |
69 :: |
84 :: |
207 |
226 |
208 {{{ Show the annotation that has appeared on the plot }}} |
227 {{{ Show the annotation that has appeared on the plot }}} |
209 As you can see, the first argument to =annotate= command is the name we would |
228 As you can see, the first argument to =annotate= command is the name we would |
210 like to mark the point as and the argument after xy= is the point at which the |
229 like to mark the point as and the argument after xy= is the point at which the |
211 name should appear. |
230 name should appear. |
|
231 |
|
232 .. #[[Anoop: I think we should tell explicitely that xy takes a |
|
233 sequence or a tuple]] |
212 |
234 |
213 {{{ Pause here and try out the following exercises }}} |
235 {{{ Pause here and try out the following exercises }}} |
214 |
236 |
215 %% 6 %% Make an annotation called "root" at the point (-4, 0) |
237 %% 6 %% Make an annotation called "root" at the point (-4, 0) |
216 What happens to the first annotation ? |
238 What happens to the first annotation ? |