I\'m adding a matplotlib figure to a canvas so that I may integrate it with pyqt in my application. I were looking around and using plt.add_subplot(111)
seem to
plt.subplot
returns a subplot object which is a type of axes object. It has two methods for adding axis labels: set_xlabel and set_ylabel:
ax = plt.subplot('111')
ax.set_xlabel('X Axis')
ax.set_ylabel('Y Axis')
You could also call plt.xlabel
and plt.ylabel
(like you did before) and specify the axes to which you want the label applied.
ax = plt.subplot('111')
plt.xlabel('X Axis', axes=ax)
plt.ylabel('Y Axis', axes=ax)
Since you only have one axes, you could also omit the axes
kwarg since the label will automatically be applied to the current axes if one isn't specified.
ax = plt.subplot('111')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')