Skip to main contentSkip to solution

Which of the following function will be used to label the x axis of a plot?

Solution

✅ Correct Option: 2

In Matplotlib, plt.xlabel("text") sets the label of the x-axis of the current plot. For example, plt.xlabel("Time") writes "Time" below the x-axis.

plt.ylabel() does the same for the y-axis.


Option 1: xaxis is an attribute of an Axes object (as in ax.xaxis), not a pyplot function that sets a label.

Options 3 and 4: plt.setx() and plt.axislabel() do not exist in pyplot.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question