Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are several ways to modify the arrow axes and their tick labels in a Matplotlib plot:

  1. Change the style and color of the arrow axes:
# Set arrow style and color
ax.xaxis.set_ticks_position('none')  # hide x-axis arrow
ax.yaxis.set_ticks_position('none')  # hide y-axis arrow
ax.spines['bottom'].set_color('gray')  # change x-axis color
ax.spines['left'].set_color('gray')  # change y-axis color
  1. Modify the tick labels:
# Set tick positions and labels
ax.set_xticks([0, 2, 4, 6, 8, 10])
ax.set_xticklabels(['0', '2', '4', '6', '8', '10'])
ax.set_yticks([0, 20, 40, 60, 80, 100])
ax.set_yticklabels(['0', '20', '40', '60', '80', '100'])
  1. Rotate the tick labels:
# Rotate tick labels
plt.xticks(rotation=45)
plt.yticks(rotation=45)
  1. Add a label to the arrow axes:
# Add axis labels
ax.set_xlabel('xlabel', fontsize=12)
ax.set_ylabel('ylabel', fontsize=12)
  1. Change the font size of the tick labels and axis labels:
# Set font size
plt.rcParams.update({'font.size': 10})