MCQs on Plotting Basics | MATLAB

2D Plots (Plot, Scatter, Bar)

  1. Which function is used to create a basic line plot in Matplotlib?
    • A) plot()
    • B) bar()
    • C) scatter()
    • D) plot2d()
  2. What does the scatter() function do in Matplotlib?
    • A) Creates a line plot
    • B) Creates a scatter plot
    • C) Creates a bar chart
    • D) Creates a pie chart
  3. In Matplotlib, how do you create a bar chart?
    • A) scatter()
    • B) bar()
    • C) plot()
    • D) line()
  4. What argument is used in the scatter() function to specify the color of points?
    • A) color
    • B) c
    • C) marker
    • D) linestyle
  5. How can you specify the color of bars in a bar chart in Matplotlib?
    • A) color='red'
    • B) colors='blue'
    • C) color='bar'
    • D) color='green'
  6. Which of the following is true for a scatter plot in Matplotlib?
    • A) It uses markers for each data point
    • B) It connects the points with a line
    • C) It uses bars to represent data
    • D) It doesn’t display data points
  7. Which function would you use to add data points in a plot as a series of dots?
    • A) plot()
    • B) scatter()
    • C) bar()
    • D) histogram()
  8. What does the bar() function require as its arguments in Matplotlib?
    • A) x values, y values
    • B) x values, height
    • C) x, y, labels
    • D) None of the above
  9. What would be the default color of a plot created using the plot() function?
    • A) Red
    • B) Blue
    • C) Green
    • D) Black
  10. Which of these is the correct way to add a grid to a plot in Matplotlib?
    • A) grid=True
    • B) grid()
    • C) add_grid()
    • D) plt.grid()

Formatting Plots (Labels, Titles, Legends)

  1. To add a title to a plot in Matplotlib, which function is used?
    • A) title()
    • B) set_title()
    • C) add_title()
    • D) plot_title()
  2. How can you label the x-axis in a Matplotlib plot?
    • A) xlabel()
    • B) xaxis()
    • C) set_xlabel()
    • D) x_label()
  3. How do you set the label for the y-axis in Matplotlib?
    • A) ylabel()
    • B) yaxis()
    • C) set_ylabel()
    • D) y_label()
  4. Which function is used to display a legend in Matplotlib?
    • A) legend()
    • B) show_legend()
    • C) add_legend()
    • D) set_legend()
  5. How would you add multiple labels to a plot in Matplotlib?
    • A) By adding multiple legend() calls
    • B) By using set_labels()
    • C) By passing a list to legend()
    • D) By adding each label individually
  6. What function is used to modify the font size of the title in a Matplotlib plot?
    • A) set_font_size()
    • B) fontsize()
    • C) title(fontsize=)
    • D) set_title(fontsize=)
  7. Which of these options is used to display the legend at the top left corner?
    • A) legend(position=”top_left”)
    • B) legend(loc=”upper left”)
    • C) legend(top_left=True)
    • D) set_legend(position=”top_left”)
  8. To add labels to the axes in a 2D plot, which method is used?
    • A) set_labels()
    • B) xlabel() and ylabel()
    • C) set_title()
    • D) axes_labels()
  9. How would you increase the font size of the axis labels in Matplotlib?
    • A) set_fontsize()
    • B) axes_labels(fontsize=)
    • C) xlabel(fontsize=), ylabel(fontsize=)
    • D) font_size=labels()
  10. In which function do you specify the location of the legend in Matplotlib?
    • A) legend()
    • B) plt.legend()
    • C) ax.legend()
    • D) legend(location=)

Subplots

  1. Which function is used to create multiple subplots in a single figure in Matplotlib?
    • A) subplot()
    • B) subplots()
    • C) add_subplot()
    • D) create_subplots()
  2. How do you create a 2×2 grid of subplots in Matplotlib?
    • A) subplots(2, 2)
    • B) subplot(2, 2)
    • C) subplots(2, 2, figsize=(8, 8))
    • D) plt.subplots(2, 2)
  3. To access the first subplot in a 2×2 grid, which index is used?
    • A) ax[0]
    • B) ax[1]
    • C) ax[2]
    • D) ax[3]
  4. How do you specify the size of a subplot in Matplotlib?
    • A) figsize=()
    • B) set_size()
    • C) subplot_size=()
    • D) set_figsize()
  5. What does the tight_layout() function do in Matplotlib?
    • A) Adjusts spacing between subplots
    • B) Creates a grid layout
    • C) Plots the figure
    • D) Sets the figure size
  6. What is the purpose of the sharex and sharey parameters in subplots()?
    • A) They share the axis between subplots
    • B) They define the subplot size
    • C) They add titles to subplots
    • D) They create separate axes

Saving and Exporting Figures

  1. Which function is used to save a figure to a file in Matplotlib?
    • A) save()
    • B) savefig()
    • C) export()
    • D) writefig()
  2. What is the default file format when using savefig() if no extension is specified?
    • A) PDF
    • B) PNG
    • C) JPG
    • D) SVG
  3. Which of these is a valid file extension to save a plot as an image using Matplotlib?
    • A) .jpg
    • B) .png
    • C) .svg
    • D) All of the above
  4. To save a figure as a .pdf file, what would the savefig() function call look like?
    • A) savefig(‘plot.pdf’)
    • B) save(‘plot.pdf’)
    • C) savefig(plot, format=’pdf’)
    • D) export(‘plot.pdf’)

Answers

QnoAnswer (Option with Text)
1A) plot()
2B) Creates a scatter plot
3B) bar()
4B) c
5A) color='red'
6A) It uses markers for each data point
7B) scatter()
8B) x values, height
9B) Blue
10D) plt.grid()
11B) set_title()
12C) set_xlabel()
13C) set_ylabel()
14A) legend()
15C) By passing a list to legend()
16C) title(fontsize=)
17B) legend(loc=”upper left”)
18B) xlabel() and ylabel()
19C) xlabel(fontsize=), ylabel(fontsize=)
20B) plt.legend()
21B) subplots()
22A) subplots(2, 2)
23A) ax[0]
24A) figsize=()
25A) Adjusts spacing between subplots
26A) They share the axis between subplots
27B) savefig()
28B) PNG
29D) All of the above
30A) savefig(‘plot.pdf’)

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top