author | Madhusudan.C.S <madhusudancs@gmail.com> |
Mon, 20 Sep 2010 11:52:17 +0530 | |
changeset 172 | 438e7bae3cf3 |
parent 159 | 8efa612b17e1 |
child 173 | 24289d3a4fdb |
permissions | -rw-r--r-- |
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
1 |
Hello friends and welcome to the tutorial on Embellishing Plots. |
129 | 2 |
|
3 |
{{{ Show the slide containing title }}} |
|
4 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
5 |
{{{ Show the slide containing the outline }}} |
129 | 6 |
|
7 |
In this tutorial, we shall look at how to modify the colour, thickness and |
|
8 |
linestyle of the plot. We shall then learn how to add title to the plot and |
|
9 |
then look at adding labels to x and y axes. we shall also look at adding |
|
10 |
annotations to the plot. |
|
11 |
||
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
12 |
Let us start ipython with pylab loaded, by typing |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
13 |
:: |
129 | 14 |
|
15 |
ipython -pylab |
|
16 |
||
17 |
on the terminal |
|
18 |
||
159 | 19 |
{{{ shift to terminal and type ipython -pylab }}} |
129 | 20 |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
21 |
#[madhu: I feel the instructions should precede the actual action, |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
22 |
since while recording we need to know before hand what we need to do] |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
23 |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
24 |
We shall first make a simple plot and start with decorating it. |
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
25 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
26 |
.. #[madhu: start decorating it should be fine, with is not necessary] |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
27 |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
28 |
:: |
129 | 29 |
|
30 |
x = linspace(-2, 4, 20) |
|
31 |
plot(x, sin(x)) |
|
32 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
33 |
.. #[madhu: Standard is to choose between -50 to 50 or 0 to 50 with 100 |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
34 |
points right?] |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
35 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
36 |
As you can see, the default colour and the default thickness of the |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
37 |
line is as decided by pylab. Wouldn't be nice if we could control |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
38 |
these parameters in the plot? Yes, this is possible by passing additional |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
39 |
arguments to the plot command. |
129 | 40 |
|
159 | 41 |
.. #[[Anoop: I think it will be good to rephrase the sentence]] |
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
42 |
.. #[madhu: Why "you" here? Shouldn't this be "we" as decided? Also I |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
43 |
added "the default" check the diff] |
159 | 44 |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
45 |
The additional argument that we shall be passing in here now is the |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
46 |
colour argument. We shall first clear the figure and plot the same in |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
47 |
red colour. Hence |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
48 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
49 |
.. #[Madhu: Note the diff for changes] |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
50 |
:: |
129 | 51 |
|
52 |
clf() |
|
53 |
plot(x, sin(x), 'r') |
|
54 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
55 |
As we can see we have the same plot but now in red colour. |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
56 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
57 |
.. #[Madhu: diff again] |
129 | 58 |
|
59 |
To alter the thickness of the line, we use the =linewidth= argument in the plot |
|
159 | 60 |
command. Hence |
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
61 |
:: |
129 | 62 |
|
63 |
plot(x, cos(x), linewidth=2) |
|
64 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
65 |
produces a plot with a thicker line, to be more precise plot with line |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
66 |
thickness 2. |
129 | 67 |
|
159 | 68 |
.. #[[Anoop: I guess it will be good if you say that it affects the |
69 |
same plot, as you have not cleared the figure]] |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
70 |
.. #[Madhu: To Anoop, not necessary I feel since they can see it?] |
159 | 71 |
|
72 |
{{{ Show the plot and compare the sine and cos plots }}} |
|
129 | 73 |
|
74 |
{{{ Pause here and try out the following exercises }}} |
|
75 |
||
159 | 76 |
.. #[[Anoop: is the above a context switch for the person who does the |
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
77 |
recording, other wise if it an instruction to the person viewing |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
78 |
the video, then I guess the three braces can be removed.]] |
159 | 79 |
|
129 | 80 |
%% 1 %% Plot sin(x) in blue colour and with linewidth as 3 |
81 |
||
82 |
{{{ continue from paused state }}} |
|
83 |
||
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
84 |
A combination of colour and linewidth would do the job for us. Hence |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
85 |
:: |
129 | 86 |
|
87 |
plot(x, sin(x), 'b', linewidth=3) |
|
88 |
||
159 | 89 |
.. #[[Anoop: add clf()]] |
90 |
||
129 | 91 |
produces the required plot |
92 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
93 |
#[Nishanth]: I could not think of a SIMPLE recipe approach for |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
94 |
introducing linestyle. Hence the naive approach. |
129 | 95 |
|
159 | 96 |
.. #[[Anoop: I guess the recipe is fine, but would be better if you |
97 |
add the problem statement rather than just saying "let's do a simple |
|
98 |
plot"]] |
|
99 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
100 |
.. #[Madhu: It is good enough.] |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
101 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
102 |
Occasionally we would also want to alter the style of line. Sometimes |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
103 |
all we want is just a bunch of points not joined. This is possible by |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
104 |
passing the linestyle argument along with or instead of the colour |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
105 |
argument. Hence :: |
129 | 106 |
|
107 |
clf() |
|
108 |
plot(x, sin(x), '.') |
|
109 |
||
110 |
produces a plot with only points. |
|
111 |
||
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
112 |
To produce the same plot but now in blue colour, we do |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
113 |
:: |
129 | 114 |
|
115 |
clf() |
|
116 |
plot(x, sin(x), 'b.') |
|
117 |
||
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
118 |
Other available options can be seen in the documentation of plot. |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
119 |
:: |
129 | 120 |
|
121 |
plot? |
|
122 |
||
123 |
{{{ Run through the documentation and show the options available }}} |
|
124 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
125 |
.. #[Madhu: The script needs to tell what needs to be shown or |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
126 |
explained.] |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
127 |
|
129 | 128 |
{{{ Pause here and try out the following exercises }}} |
129 |
||
159 | 130 |
.. #[[Anoop: same question as above, should it be read out?]] |
131 |
||
129 | 132 |
%% 2 %% Plot the sine curve with green filled circles. |
133 |
||
134 |
{{{ continue from paused state }}} |
|
135 |
||
136 |
All we have to do is use a combination of linestyle and colour to acheive this. |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
137 |
Hence |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
138 |
:: |
129 | 139 |
|
140 |
clf() |
|
141 |
plot(x, cos(x), 'go') |
|
142 |
||
143 |
produces the required plot. |
|
144 |
||
145 |
{{{ Pause here and try out the following exercises }}} |
|
146 |
||
147 |
%% 3 %% Produce a plot of tangent curve with red dashed line and linewidth 3 |
|
148 |
||
149 |
{{{ continue from paused state }}} |
|
150 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
151 |
.. #[Madhu: I did not understand the question] |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
152 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
153 |
Now that we know how to produce a bare minimum plot with colour, style |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
154 |
and thickness of our interest, we shall look at decorating the plot. |
129 | 155 |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
156 |
Let us start with a plot of the function -x^2 + 4x - 5. |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
157 |
:: |
129 | 158 |
|
159 |
plot(x, -x*x + 4*x - 5, 'r', linewidth=2) |
|
160 |
||
161 |
{{{ Show the plot window and switch back to terminal }}} |
|
162 |
||
163 |
We now have the plot in a colour and linewidth of our interest. As you can see, |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
164 |
the figure does not have any description describing the plot. |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
165 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
166 |
.. #[Madhu: Added "not". See the diff] |
129 | 167 |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
168 |
We will now add a title to the plot by using the =title= command. |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
169 |
:: |
129 | 170 |
|
171 |
title("Parabolic function -x^2+4x-5") |
|
172 |
||
173 |
{{{ Show the plot window and point to the title }}} |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
174 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
175 |
The figure now has a title which describes what the plot is. The |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
176 |
=title= command as you can see, takes a string as an argument and sets |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
177 |
the title accordingly. |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
178 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
179 |
.. #[Madhu: See the diff] |
129 | 180 |
|
181 |
The formatting in title is messed and it does not look clean. You can imagine |
|
182 |
what would be the situation if there were fractions and more complex functions |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
183 |
like log and exp. Wouldn't it be good if there was LaTex like formatting? |
129 | 184 |
|
185 |
That is also possible by adding a $ sign before and after the part of the |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
186 |
string that should be in LaTex style. |
129 | 187 |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
188 |
for instance, we can use |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
189 |
:: |
129 | 190 |
|
191 |
title("Parabolic function $-x^2+4x-5$") |
|
192 |
||
193 |
and we get the polynomial formatted properly. |
|
194 |
||
130 | 195 |
#[Nishanth]: Unsure if I have to give this exercise since enclosing the whole |
196 |
string in LaTex style is not good |
|
197 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
198 |
.. #[[Anoop: I guess you can go ahead with the LaTex thing, it's |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
199 |
cool!]] |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
200 |
.. #[Madhu: Instead of saying LaTeX style you can say Typeset math |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
201 |
since that is how it is called as. I am not sure as well. It |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
202 |
doesn't really solve the purpose] |
159 | 203 |
|
129 | 204 |
{{{ Pause here and try out the following exercises }}} |
205 |
||
206 |
%% 4 %% Change the title of the figure such that the whole title is formatted |
|
207 |
in LaTex style |
|
208 |
||
209 |
{{{ continue from the paused state }}} |
|
210 |
||
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
211 |
The solution is to enclose the whole string in between $. Hence, |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
212 |
:: |
129 | 213 |
|
214 |
title("$Parabolic function -x^2+4x-5$") |
|
215 |
||
216 |
gives a title that looks neatly formatted. |
|
217 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
218 |
Although we have title, the plot is not complete without labelling x |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
219 |
and y axes. Hence we shall label x-axis to "x" and y-axis to "f(x)" :: |
129 | 220 |
|
221 |
xlabel("x") |
|
222 |
||
223 |
{{{ Switch to plot window and show the xlabel }}} |
|
224 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
225 |
As you can see, =xlabel= command takes a string as an argument, |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
226 |
similar to the =title= command and sets it as the label to x-axis. |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
227 |
|
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
228 |
.. #[See the diff] |
129 | 229 |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
230 |
Similarly, |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
231 |
:: |
129 | 232 |
|
233 |
ylabel("f(x)") |
|
234 |
||
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
235 |
sets the name of the y-axis as "f(x)" |
129 | 236 |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
237 |
{{{ Show the plot window and point to ylabel and switch back to the terminal }}} |
129 | 238 |
|
239 |
{{{ Pause here and try out the following exercises }}} |
|
240 |
||
241 |
%% 5 %% Set the x and y labels as "x" and "f(x)" in LaTex style. |
|
242 |
||
243 |
{{{ continue from paused state }}} |
|
244 |
||
245 |
Since we need LaTex style formatting, all we have to do is enclose the string |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
246 |
in between two $. Hence, |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
247 |
:: |
129 | 248 |
|
249 |
xlabel("$x$") |
|
250 |
yalbel("$f(x)$") |
|
251 |
||
252 |
does the job for us. |
|
253 |
||
254 |
{{{ Show the plot window with clean labels }}} |
|
255 |
||
256 |
The plot is now almost complete. Except that we have still not seen how to |
|
257 |
name the points. For example the point (2, -1) is the local maxima. We would |
|
138
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
258 |
like to name the point accordingly. We can do this by using |
85ed0d5d28f8
added a newline before :: so that a colon does not appear in html
nishanth
parents:
130
diff
changeset
|
259 |
:: |
129 | 260 |
|
261 |
annotate("local maxima", xy=(2, -1)) |
|
262 |
||
263 |
{{{ Show the annotation that has appeared on the plot }}} |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
264 |
|
129 | 265 |
As you can see, the first argument to =annotate= command is the name we would |
266 |
like to mark the point as and the argument after xy= is the point at which the |
|
267 |
name should appear. |
|
268 |
||
159 | 269 |
.. #[[Anoop: I think we should tell explicitely that xy takes a |
270 |
sequence or a tuple]] |
|
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
271 |
.. #[Madhu: Agreed to what anoop says and also that xy= is the point |
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
272 |
part should be rephrased I think.] |
159 | 273 |
|
129 | 274 |
{{{ Pause here and try out the following exercises }}} |
275 |
||
276 |
%% 6 %% Make an annotation called "root" at the point (-4, 0) |
|
277 |
What happens to the first annotation ? |
|
278 |
||
279 |
{{{ continue from paused state }}} |
|
280 |
||
281 |
As we can see, every annotate command makes a new annotation on the figure. |
|
282 |
||
283 |
{{{ Show summary slide }}} |
|
284 |
||
285 |
we have looked at |
|
286 |
||
287 |
* Modifying the attributes of plot by passing additional arguments |
|
288 |
* How to add title |
|
289 |
* How to incorporate LaTex style formatting |
|
290 |
* How to label x and y axes |
|
291 |
* How to add annotations |
|
292 |
||
293 |
{{{ Show the "sponsored by FOSSEE" slide }}} |
|
294 |
||
295 |
#[Nishanth]: Will add this line after all of us fix on one. |
|
296 |
This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India |
|
297 |
||
298 |
Hope you have enjoyed and found it useful. |
|
299 |
Thankyou |
|
300 |
||
301 |
.. Author : Nishanth |
|
159 | 302 |
Internal Reviewer 1 : Anoop |
172
438e7bae3cf3
Second Review for embellishing plot.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
159
diff
changeset
|
303 |
Internal Reviewer 2 : Madhu |
129 | 304 |
External Reviewer : |