<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python%2FC2%2FEmbellishing-a-plot%2FEnglish</id>
		<title>Python/C2/Embellishing-a-plot/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python%2FC2%2FEmbellishing-a-plot%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python/C2/Embellishing-a-plot/English&amp;action=history"/>
		<updated>2026-05-13T01:59:48Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Python/C2/Embellishing-a-plot/English&amp;diff=928&amp;oldid=prev</id>
		<title>Pravin1389: moved Python/C2/Embellishing-a-plot /English to Python/C2/Embellishing-a-plot/English</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python/C2/Embellishing-a-plot/English&amp;diff=928&amp;oldid=prev"/>
				<updated>2012-12-02T06:26:56Z</updated>
		
		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/index.php/Python/C2/Embellishing-a-plot_/English&quot; class=&quot;mw-redirect&quot; title=&quot;Python/C2/Embellishing-a-plot /English&quot;&gt;Python/C2/Embellishing-a-plot /English&lt;/a&gt; to &lt;a href=&quot;/index.php/Python/C2/Embellishing-a-plot/English&quot; title=&quot;Python/C2/Embellishing-a-plot/English&quot;&gt;Python/C2/Embellishing-a-plot/English&lt;/a&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 06:26, 2 December 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Pravin1389</name></author>	</entry>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Python/C2/Embellishing-a-plot/English&amp;diff=443&amp;oldid=prev</id>
		<title>Chandrika: Created page with '{| border=1 !Visual Cue !Narration |-  | Show Slide 1  containing title, name of the production team along with the logo of MHRD  | Welcome to the tutorial on &quot;Embellishing a Plo…'</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python/C2/Embellishing-a-plot/English&amp;diff=443&amp;oldid=prev"/>
				<updated>2012-11-29T05:54:20Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;{| border=1 !Visual Cue !Narration |-  | Show Slide 1  containing title, name of the production team along with the logo of MHRD  | Welcome to the tutorial on &amp;quot;Embellishing a Plo…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| border=1&lt;br /&gt;
!Visual Cue&lt;br /&gt;
!Narration&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Show Slide 1&lt;br /&gt;
&lt;br /&gt;
containing title, name of the production team along with the logo of MHRD &lt;br /&gt;
| Welcome to the tutorial on &amp;quot;Embellishing a Plot&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 2 &lt;br /&gt;
&lt;br /&gt;
Learning objectives &lt;br /&gt;
| At the end of this tutorial, you will be able to,&lt;br /&gt;
&lt;br /&gt;
# Modify the attributes of the plot -- color, line style,linewidth.&lt;br /&gt;
# Add a title to the plot with embedded LaTeX.&lt;br /&gt;
# Label x and y axes.&lt;br /&gt;
# Add annotations to the plot.&lt;br /&gt;
# Set and Get the limits of axes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 3 &lt;br /&gt;
&lt;br /&gt;
Show slide with pre-requisite &lt;br /&gt;
&lt;br /&gt;
open the terminal and type ipython -pylab &lt;br /&gt;
&lt;br /&gt;
 ipython -pylab&lt;br /&gt;
| Before beginning this tutorial,we would suggest you to complete the tutorial on &amp;quot;Using plot interactively&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Let us start ipython with pylab loaded, open the terminal and type&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  x = linspace(-2, 4, 20)&lt;br /&gt;
 plot(x, sin(x))&lt;br /&gt;
| We shall first make a simple plot and start decorating it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  clf()&lt;br /&gt;
 plot(x, sin(x), 'r')&lt;br /&gt;
| As we can see, the default colour and the default thickness of the line is as decided by pylab. Wouldn't it be nice if we could control these parameters in the plot? This is possible by passing additional arguments to the plot command. We shall first clear the figure and plot the same by passing the additional color argument. Pass the argument 'r' for red color.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Move the mouse pointer on the plot &lt;br /&gt;
| The same plot is seen in red color.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal &lt;br /&gt;
&lt;br /&gt;
 plot(x, cos(x), linewidth=2)&lt;br /&gt;
| The thickness of the line can be altered by 'linewidth' argument.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show the plot and compare the sine and cos plots &lt;br /&gt;
| A plot with line thickness 2 is produced.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 4&lt;br /&gt;
&lt;br /&gt;
Assignment 1 &lt;br /&gt;
| Pause the video and do this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
Plot sin(x) in blue color along with linewidth as 3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal &lt;br /&gt;
&lt;br /&gt;
 clf()&lt;br /&gt;
 plot(x, sin(x), 'b', linewidth=3)&lt;br /&gt;
| Switch to terminal for solution A combination of color and linewidth would do the job for us.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  clf()&lt;br /&gt;
 plot(x, sin(x), '.')&lt;br /&gt;
| To get the style of line as bunch of points not joined, pass the linestyle argument with or without color argument.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Point at the dots on the plot &lt;br /&gt;
| We get a plot with only points.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  clf()&lt;br /&gt;
 plot(x, sin(x), 'b.')&lt;br /&gt;
| To get the same plot in blue color.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  plot?&lt;br /&gt;
&lt;br /&gt;
Run through the documentation and show the options available &lt;br /&gt;
&lt;br /&gt;
Show the options available for line style and colors &lt;br /&gt;
| Other available options for passing arguments can be seen in the documentation of plot.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 5&lt;br /&gt;
&lt;br /&gt;
Assignment 2 &lt;br /&gt;
| Pause the video and do this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
Plot the sine curve with green filled circles.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal and type the following commands &lt;br /&gt;
&lt;br /&gt;
 clf()&lt;br /&gt;
 plot(x, cos(x), 'go')&lt;br /&gt;
| Switch to terminal for solution. We use a combination of linestyle and color.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 6&lt;br /&gt;
&lt;br /&gt;
Assessment 3 &lt;br /&gt;
| Pause the video here, try out the following exercise and resume the video.&lt;br /&gt;
&lt;br /&gt;
Plot the curve of x vs tan(x) in red dash line and linewidth 3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal and type the following commands &lt;br /&gt;
&lt;br /&gt;
 clf()&lt;br /&gt;
 plot(x, cos(x), 'r--')&lt;br /&gt;
| Switch to terminal for solution. Here we shall use a combination of linewidth argument and linestyle.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| Now that we know how to produce a bare minimum plot with color, style and thickness of our interest, we shall look at further decorating the plot.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  plot(x, -x*x + 4*x - 5, 'r', linewidth=2)&lt;br /&gt;
&lt;br /&gt;
Show the plot window and switch back to terminal &lt;br /&gt;
| Let us start with a plot for the function -x^2 + 4x - 5.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal &lt;br /&gt;
&lt;br /&gt;
 title(&amp;quot;Parabolic function -x^2+4x-5&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;title&amp;lt;/tt&amp;gt; command as you can see, takes a string as an argument&lt;br /&gt;
&lt;br /&gt;
Show the plot window and point to the title &lt;br /&gt;
| As you can see, the figure does not have any description describing the plot.&lt;br /&gt;
&lt;br /&gt;
To add a title to the plot to describe what the plot is,use the &amp;lt;tt&amp;gt;title&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  title(&amp;quot;Parabolic function $-x^2+4x-5$&amp;quot;)&lt;br /&gt;
| The figure now has a title. But it is not formatted and does not look clean.&lt;br /&gt;
&lt;br /&gt;
It would look shabby if there were fractions and more complex functions like log and exp. Wouldn't it be good if the title is seen in LaTeX like formatting?&lt;br /&gt;
&lt;br /&gt;
This is possible by adding a &amp;lt;tt&amp;gt;$&amp;lt;/tt&amp;gt; sign before and after the part of the string that should be in LaTeX style.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Point at the polynomial &lt;br /&gt;
| As we can see, the polynomial is now formatted.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 7&lt;br /&gt;
&lt;br /&gt;
Assignment 4 &lt;br /&gt;
| Pause the video here, try out the following exercise and resume the video.&lt;br /&gt;
&lt;br /&gt;
Change the title of the figure such that the whole title is formatted in LaTeX style.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal &lt;br /&gt;
&lt;br /&gt;
 title(&amp;quot;$Parabolic function -x^2+4x-5$&amp;quot;)&lt;br /&gt;
| Switch to terminal for solution. The solution is to enclose the whole string in between $.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  xlabel(&amp;quot;x&amp;quot;)&lt;br /&gt;
 ylabel(&amp;quot;f(x)&amp;quot;)&lt;br /&gt;
| Although we have title, the plot is not complete without labelling x and y axes. we shall label x-axis to &amp;quot;x&amp;quot; and y-axis to &amp;quot;f(x)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| As you can see, &amp;lt;tt&amp;gt;xlabel&amp;lt;/tt&amp;gt; and 'ylabel' command takes a string as an argument. xlabel sets the label to x-axis as 'x' and ylabel sets the name to the y-axis as 'f(x)'.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|    Show the plot window and point to xlabel and ylabel and&lt;br /&gt;
&lt;br /&gt;
Unexpected indentation.&lt;br /&gt;
&lt;br /&gt;
switch back to the terminal &lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 8&lt;br /&gt;
&lt;br /&gt;
Assignment 5 &lt;br /&gt;
| Pause the video here, try out the following exercise and resume the video.&lt;br /&gt;
&lt;br /&gt;
Set the x and y labels as &amp;quot;x&amp;quot; and &amp;quot;f(x)&amp;quot; in LaTeX style.&lt;br /&gt;
&lt;br /&gt;
Since we need LaTeX style formatting, all we have to do is enclose the string in between two $.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal &lt;br /&gt;
&lt;br /&gt;
 xlabel(&amp;quot;$x$&amp;quot;)&lt;br /&gt;
 ylabel(&amp;quot;$f(x)$&amp;quot;)&lt;br /&gt;
| Switch to terminal for solution.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal &lt;br /&gt;
&lt;br /&gt;
 annotate(&amp;quot;local maxima&amp;quot;, xy=(2, -1))&lt;br /&gt;
&lt;br /&gt;
Show the annotation that has appeared on the plot &lt;br /&gt;
| The plot is now almost complete. Except that the points are not named. For example the point (2, -1) is the local maxima. We would like to name the point accordingly. To do this use the function &amp;lt;tt&amp;gt;annotate&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Point at the annotate command while explaining &lt;br /&gt;
| As you can see, the first argument to &amp;lt;tt&amp;gt;annotate&amp;lt;/tt&amp;gt; command is the name we would like to mark the point as, and the second argument is the co-ordinates of the point at which the name should appear. It is a tuple containing two numbers. The first is x co-ordinate and second is y co-ordinate.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 9 &lt;br /&gt;
&lt;br /&gt;
Assignment 6 &lt;br /&gt;
| Pause the video, do this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
Make an annotation called &amp;quot;root&amp;quot; at the point (-4, 0). What happens to the first annotation ?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to the terminal and type the command &lt;br /&gt;
&lt;br /&gt;
 annotate(&amp;quot;root&amp;quot;, xy=(-4,0))&lt;br /&gt;
| Switch to the terminal for the solution. As we can see, every annotate command makes a new annotation on the figure.&lt;br /&gt;
&lt;br /&gt;
Now we have everything we need to decorate a plot, but the plot would be incomplete if we can not set the limits of axes. This can be done using the button provided on the plot window.&lt;br /&gt;
&lt;br /&gt;
Else limits also can be get and set from the terminal. Use &amp;quot;xlim()&amp;quot; and &amp;quot;ylim()&amp;quot; functions to get the limits.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  xlim()&lt;br /&gt;
 ylim()&lt;br /&gt;
| &amp;lt;tt&amp;gt;xlim&amp;lt;/tt&amp;gt; function returns the current x axis limits and &amp;lt;tt&amp;gt;ylim&amp;lt;/tt&amp;gt; function returns the current y-axis limits.&lt;br /&gt;
&lt;br /&gt;
Set the limits of x-axis from -4 to 5 by giving command xlim(-4,5).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  xlim(-4, 5)&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  ylim(-15, 2)&lt;br /&gt;
| Similarly set the limits of y-axis appropriately.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 10 &lt;br /&gt;
&lt;br /&gt;
Assignment 7 &lt;br /&gt;
| Pause the video, do this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
Set the limits of axes such that the area of interest is the rectangle (-1, -15) and (3, 0)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Switch to terminal &lt;br /&gt;
&lt;br /&gt;
 xlim(-1, 3)&lt;br /&gt;
 ylim(-15, 0)&lt;br /&gt;
| Switch to the terminal for the solution. As we can see, the lower and upper limits of x-axis in the exercise are -1 and 3 respectively. The lower and upper limits of y-axis are -15 and 0 respectively.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| This gives us the required rectangle.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 11 &lt;br /&gt;
&lt;br /&gt;
Summary slide &lt;br /&gt;
| This brings us to the end of this tutorial.In this tutorial,we have learnt to,&lt;br /&gt;
&lt;br /&gt;
# Modify the attributes of plot like color, line width, line style by passing additional arguments.&lt;br /&gt;
# Add title to a plot using 'title' command.&lt;br /&gt;
# Incorporate LaTeX style formatting by adding a &amp;lt;tt&amp;gt;$&amp;lt;/tt&amp;gt; sign before and after the part of the string.&lt;br /&gt;
# Label x and y axes using xlabel() and ylabel() commands.&lt;br /&gt;
# Add annotations to a plot using annotate() command.&lt;br /&gt;
# Get and set the limits of axes using xlim() and ylim() commands.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 12&lt;br /&gt;
&lt;br /&gt;
Self assessment questions' slide &lt;br /&gt;
| Here are some self assessment questions for you to solve.&lt;br /&gt;
&lt;br /&gt;
# Draw a plot of cosine graph between -2pi to 2pi with line thickness 4.&lt;br /&gt;
# Read through the documentation and find out, is there a way to modify the alignment of text in the command &amp;lt;tt&amp;gt;ylabel&amp;lt;/tt&amp;gt;.&lt;br /&gt;
** Yes&lt;br /&gt;
** No&lt;br /&gt;
# How do you set the title as x^2-5x+6 in LaTex style formatting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 13 &lt;br /&gt;
&lt;br /&gt;
Solutions for the self assessment questions &lt;br /&gt;
| And the answers,&lt;br /&gt;
&lt;br /&gt;
1. In order to plot a cosine graph between the points -2pi and 2pi with line thickness 3,we use the &amp;lt;tt&amp;gt;linspace&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;plot&amp;lt;/tt&amp;gt; command as,&lt;br /&gt;
&lt;br /&gt;
 x = linspace(-2*pi, 2*pi)&lt;br /&gt;
 plot(x, cos(x), linewidth=4)&lt;br /&gt;
&lt;br /&gt;
# No. We do not have an option to modify the alignment of text in the command &amp;lt;tt&amp;gt;ylabel&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# To set the title in LaTex style formatting,we write the equation between two dollar signs as,&lt;br /&gt;
&lt;br /&gt;
 title(&amp;quot;$x^2-5x+6$&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Show Slide 14&lt;br /&gt;
&lt;br /&gt;
Acknowledgment slide &lt;br /&gt;
| Hope you have enjoyed this tutorial and found it useful. Thank you!&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Chandrika</name></author>	</entry>

	</feed>