savefig/questions.rst
author anand
Mon, 08 Nov 2010 01:36:47 +0530
changeset 455 f5b7d0b693d9
parent 353 e13e3452c599
permissions -rw-r--r--
checklist OK

Objective Questions
-------------------

.. A mininum of 8 questions here (along with answers)


1. What argument can be used with savefig to increase the resolution
   of the plot while saving a plot.

   a. fname
   #. transparency
   #. dpi
   #. format

Answer: dpi

2. The fname argument of savefig has to be always absolute path.

   a. True
   #. False

Answer: False

3. You are right now in the directory `/home/fossee`, from the
   following which one is the correct one in-order to save the plot as
   svg with the filename `plot` to the directory `/home/fossee/sine/`

   a. savefig('/sine/plot.svg')
   #. savefig('sine/plot.svg')
   #. savefig('home/fossee/sine/plot.svg')
   #. All of these
   #. None of the above

Answer: savefig('sine/plot.svg')

4. Which is the best image format to be used with Latex documents
   which savefig supports?

   a. SVG - Scalable Vector Graphics
   #. EPS - Encapsulated Post Script
   #. PS - Post Script
   #. PNG - Portable Network Graphics
   #. None of the above

Answer: EPS - Encapsulated Post Script

5. ``savefig('sine.png')`` saves the plot in,

   a. The root directory ``/`` (on GNU/Linux, Unix based systems)
      ``c:\`` (on windows).
   #. Will result in an error as full path is not supplied.
   #. The current working directory.
   #. Predefined directory like ``/documents``.

Answer: The current working directory.

6. Study the following code and tell what will happen,
   ::
      savefig('cosine.png',facecolor='blue')

   a. Will generate an error as plot statements are missing
   #. Will generate an error as full path is not specified
   #. Create a file ``cosine.png`` with blue background at the current
      working directory.
   #. Create a file ``cosine.png`` with blue background at a
      predefined directory like ``/documents``.

Answer: Create a file ``cosine.png`` with blue background at the
	current working directory.

7. How to save the below plot as ``sine_green_border.png`` with green
   color border/edge in the current working directory.  The plot is given
   as,
   ::
	x = linspace(-5*pi,5*pi,200)
	plot(x,sin(x),linewidth=2)
	legend(['sin(x)'])

   a. ``savefig('sine_green_border.png',bordercolor='green')``
   #. ``savefig('sine_green_border.png',facecolor='green')``
   #. ``savefig('sine_green_border.png',edgecolor='green')``
   #. ``savefig('/sine_green_border.png',bordercolor='green')``

Answer: savefig('sine_green_border.png',edgecolor='green')

8. Given the below code snippet, what does it do?
   ::
	x = linspace(-5*pi,5*pi,200)
	plot(x,sin(x),linewidth=2)
	legend(['sin(x)'])
    	savefig('sine.png',format='pdf',papertype='a4')

   a. Save the sine plot in file sine.png as a pdf file in page-size
      A4 and saves it into the current working directory
   #. Save the sine plot in file sine.png.pdf in page-size A4 into the
      current working directory.
   #. Save the sine plot in a file sine.png in png format with
      page-size A4 in the current working directory overriding the
      format argument
   #. Error in filename and format mismatch.

Answer: Save the sine plot in file sine.png as a pdf file in page-size
	A4 and saves it into the current working directory

.. #[Puneeth: Good questions, but can we use it in quiz? most of it
.. has not been taught in the tutorial.]

Larger Questions
----------------

.. A minimum of 2 questions here (along with answers)

1. Plot a cosine plot from -2pi to 2pi in green color taking 300
   points. Title the plot as 'Cosine plot' and the legend plot with
   'cos(x)'. And save the plot as a pdf file with the filename
   cosine_plot.

2. Plot tan(x) where x varies from -4pi to 4pi in red color taking 600
   points. Title the plot as 'Tan plot' and the legend plot with
   'tan(x)'. And save the plot as a svg file with the filename
   tangent_plot.