equal
deleted
inserted
replaced
112 |
112 |
113 We can obtain the two plots in different colors using the following |
113 We can obtain the two plots in different colors using the following |
114 commands:: |
114 commands:: |
115 |
115 |
116 x = linspace(-5, 5, 100) |
116 x = linspace(-5, 5, 100) |
117 plot(x, 4 * (x ^ 2), 'b') |
117 plot(x, 4 * (x * x), 'b') |
118 plot(x, (2 * x) + 3, 'g') |
118 plot(x, (2 * x) + 3, 'g') |
119 |
119 |
120 Now we can use the legend command as:: |
120 Now we can use the legend command as:: |
121 |
121 |
122 legend(['Parabola', 'Straight Line']) |
122 legend(['Parabola', 'Straight Line']) |
144 figure(2) |
144 figure(2) |
145 plot(x, cos(x), 'g') |
145 plot(x, cos(x), 'g') |
146 |
146 |
147 {{{ Switch to plot window }}} |
147 {{{ Switch to plot window }}} |
148 |
148 |
149 Now we have two plots, a sine plot and a cosine plot one overlaid upon |
149 Now we have two plots, a sine plot and a cosine plot in two different |
150 the other. |
150 figures. |
151 |
151 |
152 .. #[Nishanth]: figure(1) and figure(2) give two different plots. |
152 .. #[Nishanth]: figure(1) and figure(2) give two different plots. |
153 The remaining script moves on the fact that they |
153 The remaining script moves on the fact that they |
154 give overlaid plots which is not the case. |
154 give overlaid plots which is not the case. |
155 So clear the figure and plot cos and sin without |
155 So clear the figure and plot cos and sin without |
215 figure(1) |
215 figure(1) |
216 annotate('Origin', xy=(0.0, 0.0) |
216 annotate('Origin', xy=(0.0, 0.0) |
217 figure(2) |
217 figure(2) |
218 annotate('x-intercept', xy=(0, 3)) |
218 annotate('x-intercept', xy=(0, 3)) |
219 annotate('y-intercept', xy=(0, -1.5)) |
219 annotate('y-intercept', xy=(0, -1.5)) |
220 savefig('plot2.png') |
220 savefig('/home/fossee/plot2.png') |
221 figure(1) |
221 figure(1) |
222 savefig('plot1.png') |
222 savefig('/home/fossee/plot1.png') |
223 |
223 |
224 At times we run into situations where we want to compare two plots and |
224 At times we run into situations where we want to compare two plots and |
225 in such cases we want to draw both the plots in the same plotting |
225 in such cases we want to draw both the plots in the same plotting |
226 area. The situation is such that the two plots have different regular |
226 area. The situation is such that the two plots have different regular |
227 axes which means we cannot draw overlaid plots. In such cases we can |
227 axes which means we cannot draw overlaid plots. In such cases we can |
239 {{{ Have both plot window and ipython side by side }}} |
239 {{{ Have both plot window and ipython side by side }}} |
240 |
240 |
241 in this case we have 2 so it spilts the plotting area horizontally for |
241 in this case we have 2 so it spilts the plotting area horizontally for |
242 two subplots. The second argument specifies the number of coloumns of |
242 two subplots. The second argument specifies the number of coloumns of |
243 subplots that must be created. We passed 1 as the argument so the |
243 subplots that must be created. We passed 1 as the argument so the |
244 plotting area won't be split horizontally and the last argument |
244 plotting area won't be split vertically and the last argument |
245 specifies what subplot must be created now in the order of the serial |
245 specifies what subplot must be created now in the order of the serial |
246 number. In this case we passed 1 as the argument, so the first subplot |
246 number. In this case we passed 1 as the argument, so the first subplot |
247 that is top half is created. If we execute the subplot command as |
247 that is top half is created. If we execute the subplot command as |
248 |
248 |
249 {{{ Switch to ipython }}}:: |
249 {{{ Switch to ipython }}}:: |