basic-plot.txt
changeset 29 0278e84ec327
parent 27 5712cc7589f9
child 30 143d020bbd52
equal deleted inserted replaced
28:1c875f461183 29:0278e84ec327
    94 In this case, let's add a comment at the point of origin. 
    94 In this case, let's add a comment at the point of origin. 
    95 In []: annotate('origin', xy=(0, 0))
    95 In []: annotate('origin', xy=(0, 0))
    96 
    96 
    97 The first argument is the comment string and second one is the position for it. 
    97 The first argument is the comment string and second one is the position for it. 
    98 
    98 
       
    99 As you can see, the boundary along the x-axis extends after the graph and there is an ugly blank space left on the right. Also along the y-axis, the sine plot in fact is cut by the boundary. We want to make the graph fit better. For this we shall use xlim() and ylim() to set the boundaries on the figure.
       
   100 
       
   101 In []: xlim(0, 2*pi)
       
   102 
       
   103 In []: ylim(-1.2, 1.2)
       
   104 
       
   105 The first value passed is the lower limit and the second is the upper limit. Hence when we do xlim(0, 2*pi) the boundary is set from x-value 0 to x-value 2*pi. Similarly for the y-axis.
       
   106 
    99 Ok, what do I do with all this effort . I obviously have to save it . 
   107 Ok, what do I do with all this effort . I obviously have to save it . 
   100 
   108 
   101 We save the plot by the function savefig
   109 We save the plot by the function savefig
   102 In []: savefig('sin.png') saves the figure with the name 'sin.png' in the current directory. 
   110 In []: savefig('sin.png') saves the figure with the name 'sin.png' in the current directory. 
   103 
   111