|
1 Objective Questions |
|
2 ------------------- |
|
3 |
|
4 .. A mininum of 8 questions here (along with answers) |
|
5 |
|
6 |
|
7 1. What argument can be used with savefig to increase the resolution |
|
8 of the plot while saving a plot. |
|
9 |
|
10 a. fname |
|
11 #. transparency |
|
12 #. dpi |
|
13 #. format |
|
14 |
|
15 Answer: dpi |
|
16 |
|
17 2. The fname argument of savefig has to be always absolute path. |
|
18 |
|
19 a. True |
|
20 #. False |
|
21 |
|
22 Answer: False |
|
23 |
|
24 3. You are right now in the directory `/home/fossee`, from the |
|
25 following which one is the correct one in-order to save the plot as |
|
26 svg with the filename `plot` to the directory `/home/fossee/sine/` |
|
27 |
|
28 a. savefig('/sine/plot.svg') |
|
29 #. savefig('sine/plot.svg') |
|
30 #. savefig('home/fossee/sine/plot.svg') |
|
31 #. All of these |
|
32 #. None of the above |
|
33 |
|
34 Answer: savefig('sine/plot.svg') |
|
35 |
|
36 4. Which is the best image format to be used with Latex documents |
|
37 which savefig supports? |
|
38 |
|
39 a. SVG - Scalable Vector Graphics |
|
40 #. EPS - Encapsulated Post Script |
|
41 #. PS - Post Script |
|
42 #. PNG - Portable Network Graphics |
|
43 #. None of the above |
|
44 |
|
45 Answer: EPS - Encapsulated Post Script |
|
46 |
|
47 5. ``savefig('sine.png')`` saves the plot in, |
|
48 |
|
49 a. The root directory ``/`` (on GNU/Linux, Unix based systems) |
|
50 ``c:\`` (on windows). |
|
51 #. Will result in an error as full path is not supplied. |
|
52 #. The current working directory. |
|
53 #. Predefined directory like ``/documents``. |
|
54 |
|
55 Answer: The current working directory. |
|
56 |
|
57 6. Study the following code and tell what will happen, |
|
58 :: |
|
59 savefig('cosine.png',facecolor='blue') |
|
60 |
|
61 a. Will generate an error as plot statements are missing |
|
62 #. Will generate an error as full path is not specified |
|
63 #. Create a file ``cosine.png`` with blue background at the current |
|
64 working directory. |
|
65 #. Create a file ``cosine.png`` with blue background at a |
|
66 predefined directory like ``/documents``. |
|
67 |
|
68 Answer: Create a file ``cosine.png`` with blue background at the |
|
69 current working directory. |
|
70 |
|
71 7. How to save the below plot as ``sine_green_border.png`` with green |
|
72 color border/edge in the current working directory. The plot is given |
|
73 as, |
|
74 :: |
|
75 x = linspace(-5*pi,5*pi,200) |
|
76 plot(x,sin(x),linewidth=2) |
|
77 legend(['sin(x)']) |
|
78 |
|
79 a. ``savefig('sine_green_border.png',bordercolor='green')`` |
|
80 #. ``savefig('sine_green_border.png',facecolor='green')`` |
|
81 #. ``savefig('sine_green_border.png',edgecolor='green')`` |
|
82 #. ``savefig('/sine_green_border.png',bordercolor='green')`` |
|
83 |
|
84 Answer: savefig('sine_green_border.png',edgecolor='green') |
|
85 |
|
86 8. Given the below code snippet, what does it do? |
|
87 :: |
|
88 x = linspace(-5*pi,5*pi,200) |
|
89 plot(x,sin(x),linewidth=2) |
|
90 legend(['sin(x)']) |
|
91 savefig('sine.png',format='pdf',papertype='a4') |
|
92 |
|
93 a. Save the sine plot in file sine.png as a pdf file in page-size |
|
94 A4 and saves it into the current working directory |
|
95 #. Save the sine plot in file sine.png.pdf in page-size A4 into the |
|
96 current working directory. |
|
97 #. Save the sine plot in a file sine.png in png format with |
|
98 page-size A4 in the current working directory overriding the |
|
99 format argument |
|
100 #. Error in filename and format mismatch. |
|
101 |
|
102 Answer: Save the sine plot in file sine.png as a pdf file in page-size |
|
103 A4 and saves it into the current working directory |
|
104 |
|
105 Larger Questions |
|
106 ---------------- |
|
107 |
|
108 .. A minimum of 2 questions here (along with answers) |
|
109 |
|
110 1. Plot a cosine plot from -2pi to 2pi in green color taking 300 |
|
111 points. Title the plot as 'Cosine plot' and the legend plot with |
|
112 'cos(x)'. And save the plot as a pdf file with the filename |
|
113 cosine_plot. |
|
114 |
|
115 2. Plot tan(x) where x varies from -4pi to 4pi in red color taking 600 |
|
116 points. Title the plot as 'Tan plot' and the legend plot with |
|
117 'tan(x)'. And save the plot as a svg file with the filename |
|
118 tangent_plot. |