5

How to change axis weight in matplotlib (make the axis much bolder)?

from pylab import *    
x = [5,7,5,9,11,14]
y = [4,5,3,11,15,14]
scatter(x, y, s=50, color='green',marker='h')
show()
2
  • 1
    Do you want something like axhline(linewidth=5, color='black') ? Commented Nov 13, 2013 at 8:48
  • yes, similiar to that which can make all the axis much bolder @falsetru Commented Nov 13, 2013 at 8:51

2 Answers 2

5

You can set the width of whats called a spine (a side of the axes) in Matplotlib:

fig, ax = plt.subplots()

ax.plot(np.random.randn(100).cumsum())

# The spines
plt.setp(ax.spines.values(), linewidth=3)

# The ticks
ax.xaxis.set_tick_params(width=3)
ax.yaxis.set_tick_params(width=3)

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

great! @Rutger Kassies can you explain your code at least slightly
0

Use axhline, axvline:

axhline(linewidth=5, color='black')
axvline(linewidth=5, color='black')
axhline(linewidth=5, y=max(y)*1.1, color='black')
axvline(linewidth=5, x=max(x)*1.1, color='black')

enter image description here

5 Comments

thanks @falsetru it changes only two sides, i want to change all the four sides , and also the tick marks
not exactly, still one side is remaining and the right most side does not merge with original one.@falsetru
@tester2, Sorry, I don't understand what you mean.
your code is not perfect since it can not make all the four sides bolder @ falsetru
@tester2, I added a result as a image. What do you mean for all the four sides?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.