I'm currently working on a program for graphing data, and I need a way to make the number ticks on the axis bigger, and the axis's thicker. Is there a way to do this? I have tried looking everywhere, but I can't find a single thing on it. I'm using PyQt5 with Spyder
Tick and axis parameters are assigned differently.
To access the axis lines, you can use ax.spines[<axis>]
and then use set_linewidth()
.
To set ticks parameters you either use ax.tick_params
and specify for which axis and tick type you want to apply the parameters, otherwise, access single axis through ax.xaxis
or ax.yaxis
.
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
# set the axis line width in pixels
for axis in 'left', 'bottom':
ax.spines[axis].set_linewidth(2.5)
# set the parameters for both axis: label size in font points, the line tick line
# width and length in pixels
ax.tick_params(axis='both', which='major', labelsize=20, width=2.5, length=10)
# alternatively, set for individual axis:
#ax.xaxis.set_tick_params(which='major', labelsize=20, width=2.5, length=10)
#ax.yaxis.set_tick_params(which='major', labelsize=20, width=2.5, length=10)
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.