author  Anoop Jacob Thomas<anoop@fossee.in> 
Sat, 18 Dec 2010 12:54:49 +0530  
changeset 524  b602b4dcc87d 
parent 495  139bf21a9473 
permissions  rwrr 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

1 
.. Objectives 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

2 
..  
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

3 

273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

4 
.. By the end of this tutorial you will be able to 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

5 

1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

6 
.. * Modify the attributes of the plot  color, line style, linewidth 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

7 
.. * Add a title to the plot with embedded LaTeX. 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

8 
.. * Label x and y axes. 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

9 
.. * Add annotations to the plot. 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

10 
.. * Set and Get the limits of axes. 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

11 

1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

12 

235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

13 
.. Prerequisites 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

14 
..  
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

15 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

16 
.. 1. Using the ``plot`` command interactively 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

17 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

18 
.. Author : Nishanth Amuluru 
494  19 
Internal Reviewer : Anoop 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

20 
External Reviewer : 
494  21 
Language Reviewe : Bhanukiran 
495  22 
Checklist OK? : <15112010, Anand, OK> [20101005] 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

23 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

24 
Script 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

25 
 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

26 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

27 
Hello friends and welcome to the tutorial on Embellishing Plots. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

28 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

29 
{{{ Show the slide containing title }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

30 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

31 
{{{ Show the slide containing the outline }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

32 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

33 
In this tutorial, we shall look at how to modify the colour, thickness and 
494  34 
linestyle of a plot. We shall then learn how to add title to a plot and 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

35 
then look at adding labels to x and y axes. we shall also look at adding 
494  36 
annotations to the plot and setting the limits on the axes. 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

37 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

38 
Let us start ipython with pylab loaded, by typing on the terminal 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

39 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

40 
{{{ shift to terminal and type ipython pylab }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

41 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

42 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

43 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

44 
ipython pylab 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

45 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

46 
.. #[madhu: I feel the instructions should precede the actual action, 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

47 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

48 
since while recording we need to know before hand what we need to do] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

49 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

50 
We shall first make a simple plot and start decorating it. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

51 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

52 
.. #[madhu: start decorating it should be fine, with is not necessary] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

53 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

54 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

55 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

56 
x = linspace(2, 4, 20) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

57 
plot(x, sin(x)) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

58 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

59 
.. #[madhu: Standard is to choose between 50 to 50 or 0 to 50 with 100 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

60 
points right?] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

61 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

62 
As we can see, the default colour and the default thickness of the 
494  63 
line is as decided by pylab. Wouldn't it be nice if we could control 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

64 
these parameters in the plot? This is possible by passing additional 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

65 
arguments to the plot command. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

66 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

67 
.. #[[Anoop: I think it will be good to rephrase the sentence]] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

68 
.. #[madhu: Why "you" here? Shouldn't this be "we" as decided? Also I 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

69 
added "the default" check the diff] 
524
b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

70 

235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

71 
The additional argument that we shall be passing in here now is the 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

72 
colour argument. We shall first clear the figure and plot the same in 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

73 
red colour. Hence 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

74 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

75 
.. #[Madhu: Note the diff for changes] 
524
b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

76 

b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

77 
:: 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

78 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

79 
clf() 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

80 
plot(x, sin(x), 'r') 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

81 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

82 
As we can see we have the same plot but now in red colour. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

83 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

84 
.. #[Madhu: diff again] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

85 

524
b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

86 
To alter the thickness of the line, we use the ``linewidth`` argument 
b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

87 
in the plot command. Hence :: 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

88 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

89 
plot(x, cos(x), linewidth=2) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

90 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

91 
produces a plot with a thicker line, to be more precise plot with line 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

92 
thickness 2. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

93 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

94 
.. #[[Anoop: I guess it will be good if you say that it affects the 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

95 
same plot, as you have not cleared the figure]] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

96 
.. #[Madhu: To Anoop, not necessary I feel since they can see it?] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

97 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

98 
{{{ Show the plot and compare the sine and cos plots }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

99 

524
b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

100 
Pause here and try out the following exercises, 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

101 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

102 
.. #[[Anoop: is the above a context switch for the person who does the 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

103 
recording, other wise if it an instruction to the person viewing 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

104 
the video, then I guess the three braces can be removed.]] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

105 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

106 
%% 1 %% Plot sin(x) in blue colour and with linewidth as 3 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

107 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

108 
{{{ continue from paused state }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

109 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

110 
A combination of colour and linewidth would do the job for us. Hence 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

111 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

112 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

113 
clf() 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

114 
plot(x, sin(x), 'b', linewidth=3) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

115 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

116 
.. #[[Anoop: add clf()]] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

117 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

118 
produces the required plot 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

119 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

120 
.. #[Nishanth]: I could not think of a SIMPLE recipe approach for 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

121 
introducing linestyle. Hence the naive approach. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

122 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

123 
.. #[[Anoop: I guess the recipe is fine, but would be better if you 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

124 
add the problem statement rather than just saying "let's do a simple 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

125 
plot"]] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

126 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

127 
.. #[Madhu: It is good enough.] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

128 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

129 
Occasionally we would also want to alter the style of line. Sometimes 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

130 
all we want is just a bunch of points not joined. This is possible by 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

131 
passing the linestyle argument along with or instead of the colour 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

132 
argument. Hence :: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

133 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

134 
clf() 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

135 
plot(x, sin(x), '.') 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

136 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

137 
produces a plot with only points. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

138 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

139 
To produce the same plot but now in blue colour, we do 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

140 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

141 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

142 
clf() 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

143 
plot(x, sin(x), 'b.') 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

144 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

145 
Other available options can be seen in the documentation of plot. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

146 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

147 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

148 
plot? 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

149 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

150 
{{{ Run through the documentation and show the options available }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

151 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

152 
{{{ Show the options available for line style and colors }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

153 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

154 
.. #[Madhu: The script needs to tell what needs to be shown or 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

155 
explained.] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

156 

524
b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

157 
Pause here and try out the following exercises 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

158 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

159 
.. #[[Anoop: same question as above, should it be read out?]] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

160 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

161 
%% 2 %% Plot the sine curve with green filled circles. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

162 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

163 
{{{ continue from paused state }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

164 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

165 
All we have to do is use a combination of linestyle and colour to acheive this. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

166 
Hence 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

167 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

168 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

169 
clf() 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

170 
plot(x, cos(x), 'go') 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

171 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

172 
produces the required plot. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

173 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

174 
{{{ Pause here and try out the following exercises }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

175 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

176 
%% 3 %% Plot the curve of x vs tan(x) in red dashed line and linewidth 3 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

177 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

178 
{{{ continue from paused state }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

179 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

180 
.. #[Madhu: I did not understand the question] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

181 

273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

182 
:: 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

183 
clf() 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

184 
plot(x, cos(x), 'r') 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

185 

235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

186 
Now that we know how to produce a bare minimum plot with colour, style 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

187 
and thickness of our interest, we shall look at decorating the plot. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

188 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

189 
Let us start with a plot of the function x^2 + 4x  5. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

190 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

191 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

192 
plot(x, x*x + 4*x  5, 'r', linewidth=2) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

193 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

194 
{{{ Show the plot window and switch back to terminal }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

195 

273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

196 
We now have the plot in a colour and linewidth of our interest. As you 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

197 
can see, the figure does not have any description describing the plot. 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

198 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

199 
.. #[Madhu: Added "not". See the diff] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

200 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

201 
We will now add a title to the plot by using the ``title`` command. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

202 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

203 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

204 
title("Parabolic function x^2+4x5") 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

205 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

206 
{{{ Show the plot window and point to the title }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

207 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

208 
The figure now has a title which describes what the plot is. The 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

209 
``title`` command as you can see, takes a string as an argument and sets 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

210 
the title accordingly. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

211 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

212 
.. #[Madhu: See the diff] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

213 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

214 
The formatting in title is messed and it does not look clean. You can imagine 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

215 
what would be the situation if there were fractions and more complex functions 
273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

216 
like log and exp. Wouldn't it be good if there was LaTeX like formatting? 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

217 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

218 
That is also possible by adding a $ sign before and after the part of the 
273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

219 
string that should be in LaTeX style. 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

220 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

221 
for instance, we can use 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

222 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

223 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

224 
title("Parabolic function $x^2+4x5$") 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

225 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

226 
and we get the polynomial formatted properly. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

227 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

228 
.. #[Nishanth]: Unsure if I have to give this exercise since enclosing the whole 
273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

229 
string in LaTeX style is not good 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

230 

273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

231 
.. #[[Anoop: I guess you can go ahead with the LaTeX thing, it's 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

232 
cool!]] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

233 
.. #[Madhu: Instead of saying LaTeX style you can say Typeset math 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

234 
since that is how it is called as. I am not sure as well. It 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

235 
doesn't really solve the purpose] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

236 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

237 
{{{ Pause here and try out the following exercises }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

238 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

239 
%% 4 %% Change the title of the figure such that the whole title is formatted 
273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

240 
in LaTeX style 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

241 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

242 
{{{ continue from the paused state }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

243 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

244 
The solution is to enclose the whole string in between $. Hence, 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

245 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

246 

494  247 
title("Parabolic function $x^2+4x5$") 
524
b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

248 

b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

249 
.. #[[Bhanu: Dollar sign should enclose only the mathexpression. change 
b602b4dcc87d
Made some changes to the script embellishing a plot, but it still needs changes.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
495
diff
changeset

250 
made.]] 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

251 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

252 
gives a title that looks neatly formatted. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

253 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

254 
Although we have title, the plot is not complete without labelling x 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

255 
and y axes. Hence we shall label xaxis to "x" and yaxis to "f(x)" :: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

256 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

257 
xlabel("x") 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

258 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

259 
{{{ Switch to plot window and show the xlabel }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

260 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

261 
As you can see, ``xlabel`` command takes a string as an argument, 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

262 
similar to the ``title`` command and sets it as the label to xaxis. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

263 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

264 
.. #[See the diff] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

265 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

266 
Similarly, 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

267 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

268 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

269 
ylabel("f(x)") 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

270 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

271 
sets the name of the yaxis as "f(x)" 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

272 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

273 
{{{ Show the plot window and point to ylabel and switch back to the terminal }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

274 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

275 
{{{ Pause here and try out the following exercises }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

276 

273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

277 
%% 5 %% Set the x and y labels as "x" and "f(x)" in LaTeX style. 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

278 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

279 
{{{ continue from paused state }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

280 

273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

281 
Since we need LaTeX style formatting, all we have to do is enclose the string 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

282 
in between two $. Hence, 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

283 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

284 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

285 
xlabel("$x$") 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

286 
yalbel("$f(x)$") 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

287 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

288 
does the job for us. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

289 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

290 
{{{ Show the plot window with clean labels }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

291 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

292 
The plot is now almost complete. Except that we have still not seen how to 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

293 
name the points. For example the point (2, 1) is the local maxima. We would 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

294 
like to name the point accordingly. We can do this by using 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

295 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

296 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

297 
annotate("local maxima", xy=(2, 1)) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

298 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

299 
{{{ Show the annotation that has appeared on the plot }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

300 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

301 
As you can see, the first argument to ``annotate`` command is the name we would 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

302 
like to mark the point as and the second argument is the coordinates of the 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

303 
point at which the name should appear. It is a sequence containing two numbers. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

304 
The first is x coordinate and second is y coordinate. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

305 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

306 
.. #[[Anoop: I think we should tell explicitely that xy takes a 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

307 
sequence or a tuple]] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

308 
.. #[Madhu: Agreed to what anoop says and also that xy= is the point 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

309 
part should be rephrased I think.] 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

310 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

311 
{{{ Pause here and try out the following exercises }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

312 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

313 
%% 6 %% Make an annotation called "root" at the point (4, 0) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

314 
What happens to the first annotation ? 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

315 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

316 
{{{ continue from paused state }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

317 

273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

318 
:: 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

319 

1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

320 
annotate("root", xy=(4,0)) 
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

321 

235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

322 
As we can see, every annotate command makes a new annotation on the figure. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

323 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

324 
Now we have everything we need to decorate a plot. but the plot would be 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

325 
incomplete if we can not set the limits of axes. This is possible using the 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

326 
button on the plot window. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

327 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

328 
we shall look at how to get and set them from the script. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

329 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

330 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

331 
xlim() 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

332 
ylim() 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

333 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

334 
We see that ``xlim`` function returns the current x axis limits and ylim 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

335 
function returns the current yaxis limits. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

336 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

337 
Let us look at how to set the limits. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

338 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

339 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

340 
xlim(4, 5) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

341 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

342 
We see the limits of xaxis are now set to 4 and 5. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

343 
Similarly 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

344 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

345 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

346 
ylim(15, 2) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

347 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

348 
sets the limits of yaxis appropriately. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

349 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

350 
{{{ Pause here and try out the following exercises }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

351 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

352 
%% 7 %% Set the limits of axes such that the area of interest is the rectangle 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

353 
(1, 15) and (3, 0) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

354 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

355 
{{{ continue from paused state }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

356 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

357 
As we can see, the lower upper limits of xaxis in the question are 1 and 3. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

358 
The limits of yaxis are 15 and 0. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

359 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

360 
:: 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

361 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

362 
xlim(1, 3) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

363 
ylim(15, 0) 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

364 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

365 
Gives us the required rectangle. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

366 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

367 
{{{ Show summary slide }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

368 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

369 
we have looked at 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

370 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

371 
* Modifying the attributes of plot by passing additional arguments 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

372 
* How to add title 
273
1639ef25a231
Slides for embellishing a plot LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
235
diff
changeset

373 
* How to incorporate LaTeX style formatting 
235
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

374 
* How to label x and y axes 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

375 
* How to add annotations 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

376 
* How to set the limits of axes 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

377 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

378 
{{{ Show the "sponsored by FOSSEE" slide }}} 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

379 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

380 
.. #[Nishanth]: Will add this line after all of us fix on one. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

381 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

382 
This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

383 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

384 
Hope you have enjoyed and found it useful. 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

385 
Thankyou 
80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

386 

80e4016d747a
Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff
changeset

387 