# HG changeset patch # User Madhusudan.C.S # Date 1284963737 -19800 # Node ID 438e7bae3cf3b316a7a17c46889c5d7947b19194 # Parent 6537f447efc05344d44fd745bf9cd1178e316281 Second Review for embellishing plot. diff -r 6537f447efc0 -r 438e7bae3cf3 embellishing_a_plot.rst --- a/embellishing_a_plot.rst Sat Sep 18 01:25:21 2010 +0530 +++ b/embellishing_a_plot.rst Mon Sep 20 11:52:17 2010 +0530 @@ -1,8 +1,8 @@ -Hello friends and welcome to the tutorial on Embellishing Plots +Hello friends and welcome to the tutorial on Embellishing Plots. {{{ Show the slide containing title }}} -{{{ Show the slide containing the outline slide }}} +{{{ Show the slide containing the outline }}} In this tutorial, we shall look at how to modify the colour, thickness and linestyle of the plot. We shall then learn how to add title to the plot and @@ -18,26 +18,43 @@ {{{ shift to terminal and type ipython -pylab }}} +#[madhu: I feel the instructions should precede the actual action, +since while recording we need to know before hand what we need to do] + We shall first make a simple plot and start with decorating it. + +.. #[madhu: start decorating it should be fine, with is not necessary] + :: x = linspace(-2, 4, 20) plot(x, sin(x)) -As you can see, the colour and thickness of line as decided by pylab. It would -be nice if we could control these parameters in the plot. This is possible by -passing additional arguments to the plot command. +.. #[madhu: Standard is to choose between -50 to 50 or 0 to 50 with 100 + points right?] + +As you can see, the default colour and the default thickness of the +line is as decided by pylab. Wouldn't be nice if we could control +these parameters in the plot? Yes, this is possible by passing additional +arguments to the plot command. .. #[[Anoop: I think it will be good to rephrase the sentence]] +.. #[madhu: Why "you" here? Shouldn't this be "we" as decided? Also I + added "the default" check the diff] -The second argument that we shall be passing is colour. We shall first clear -the figure and plot the same in red colour. Hence -:: +The additional argument that we shall be passing in here now is the +colour argument. We shall first clear the figure and plot the same in +red colour. Hence + +.. #[Madhu: Note the diff for changes] + :: clf() plot(x, sin(x), 'r') -Plots the same curve but now in red colour. +As we can see we have the same plot but now in red colour. + +.. #[Madhu: diff again] To alter the thickness of the line, we use the =linewidth= argument in the plot command. Hence @@ -45,18 +62,20 @@ plot(x, cos(x), linewidth=2) -produces a plot with a thicker line. +produces a plot with a thicker line, to be more precise plot with line +thickness 2. .. #[[Anoop: I guess it will be good if you say that it affects the same plot, as you have not cleared the figure]] +.. #[Madhu: To Anoop, not necessary I feel since they can see it?] {{{ Show the plot and compare the sine and cos plots }}} {{{ Pause here and try out the following exercises }}} .. #[[Anoop: is the above a context switch for the person who does the - recording, other wise if it an instruction to the person viewing the - video, then I guess the three braces can be removed.]] + recording, other wise if it an instruction to the person viewing + the video, then I guess the three braces can be removed.]] %% 1 %% Plot sin(x) in blue colour and with linewidth as 3 @@ -71,17 +90,19 @@ produces the required plot -#[Nishanth]: I could not think of a SIMPLE recipe approach for introducing - linestyle. Hence the naive approach. +#[Nishanth]: I could not think of a SIMPLE recipe approach for + introducing linestyle. Hence the naive approach. .. #[[Anoop: I guess the recipe is fine, but would be better if you add the problem statement rather than just saying "let's do a simple plot"]] -Occasionally we would also want to alter the style of line. Sometimes all we -want is just a bunch of points not joined. This is possible by passing the -linestyle argument along with or instead of the colour argument.Hence -:: +.. #[Madhu: It is good enough.] + +Occasionally we would also want to alter the style of line. Sometimes +all we want is just a bunch of points not joined. This is possible by +passing the linestyle argument along with or instead of the colour +argument. Hence :: clf() plot(x, sin(x), '.') @@ -101,6 +122,9 @@ {{{ Run through the documentation and show the options available }}} +.. #[Madhu: The script needs to tell what needs to be shown or + explained.] + {{{ Pause here and try out the following exercises }}} .. #[[Anoop: same question as above, should it be read out?]] @@ -124,8 +148,10 @@ {{{ continue from paused state }}} -Now that we know how to produce a bare minimum plot with colour, style and -thickness of our interest, we shall look at decorating the plot. +.. #[Madhu: I did not understand the question] + +Now that we know how to produce a bare minimum plot with colour, style +and thickness of our interest, we shall look at decorating the plot. Let us start with a plot of the function -x^2 + 4x - 5. :: @@ -135,7 +161,9 @@ {{{ Show the plot window and switch back to terminal }}} We now have the plot in a colour and linewidth of our interest. As you can see, -the figure does have any description describing the plot. +the figure does not have any description describing the plot. + +.. #[Madhu: Added "not". See the diff] We will now add a title to the plot by using the =title= command. :: @@ -143,16 +171,19 @@ title("Parabolic function -x^2+4x-5") {{{ Show the plot window and point to the title }}} -The figure now has a title which describes what the plot is. -The =title= command as you can see, takes a string as argument and set the -title accordingly. + +The figure now has a title which describes what the plot is. The +=title= command as you can see, takes a string as an argument and sets +the title accordingly. + +.. #[Madhu: See the diff] The formatting in title is messed and it does not look clean. You can imagine what would be the situation if there were fractions and more complex functions -like log and exp. Wouldn't it be good if there was LaTex like formatting. +like log and exp. Wouldn't it be good if there was LaTex like formatting? That is also possible by adding a $ sign before and after the part of the -string that should be LaTex style. +string that should be in LaTex style. for instance, we can use :: @@ -164,7 +195,11 @@ #[Nishanth]: Unsure if I have to give this exercise since enclosing the whole string in LaTex style is not good -.. #[[Anoop: I guess you can go ahead with the LaTex thing, it's cool!]] +.. #[[Anoop: I guess you can go ahead with the LaTex thing, it's + cool!]] +.. #[Madhu: Instead of saying LaTeX style you can say Typeset math + since that is how it is called as. I am not sure as well. It + doesn't really solve the purpose] {{{ Pause here and try out the following exercises }}} @@ -180,25 +215,26 @@ gives a title that looks neatly formatted. -Although we have title, the plot is not complete without labelling x and y -axes. Hence we shall label x-axis to "x" and y-axis to "f(x)" -:: +Although we have title, the plot is not complete without labelling x +and y axes. Hence we shall label x-axis to "x" and y-axis to "f(x)" :: xlabel("x") {{{ Switch to plot window and show the xlabel }}} -As you can see, =xlabel= command takes a string as argument, similar to the -=title= command and sets it to x-axis. +As you can see, =xlabel= command takes a string as an argument, +similar to the =title= command and sets it as the label to x-axis. + +.. #[See the diff] Similarly, :: ylabel("f(x)") -sets the name of y-axis as "f(x)" +sets the name of the y-axis as "f(x)" -{{{ Show the plot window and point to ylabel and switch back to terminal }}} +{{{ Show the plot window and point to ylabel and switch back to the terminal }}} {{{ Pause here and try out the following exercises }}} @@ -225,12 +261,15 @@ annotate("local maxima", xy=(2, -1)) {{{ Show the annotation that has appeared on the plot }}} + As you can see, the first argument to =annotate= command is the name we would like to mark the point as and the argument after xy= is the point at which the name should appear. .. #[[Anoop: I think we should tell explicitely that xy takes a sequence or a tuple]] +.. #[Madhu: Agreed to what anoop says and also that xy= is the point + part should be rephrased I think.] {{{ Pause here and try out the following exercises }}} @@ -261,5 +300,5 @@ .. Author : Nishanth Internal Reviewer 1 : Anoop - Internal Reviewer 2 : + Internal Reviewer 2 : Madhu External Reviewer :