0

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

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Welcome to StackOverflow! Questions have a higher chance of being accepted if you clearly explain your problem AND demonstrate what you have tried or what you have found in your own searches. In your case, I think it would be helpful to explain and show demo code for what/how you are plotting, e.g. r u using matplotlib? If so, what have you tried there? Lots of documentation on it. – wellplayed Sep 29 '20 at 19:12
  • Does this answer your question? [matplotlib ticks thickness](https://stackoverflow.com/questions/14705904) – Trenton McKinney Sep 30 '20 at 18:22

1 Answers1

1

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()

screenshot of the example code

musicamante
  • 41,230
  • 6
  • 33
  • 58