In matplotlib I like to customize my plots by shifting the spines from the origin, for example:
plot(range(10), marker='o', ms=20)
#customize axes
axes = gca()
axes.spines['right'].set_color('none')
axes.spines['top'].set_color('none')
axes.xaxis.set_ticks_position('bottom')
axes.spines['bottom'].set_position(('axes', -0.05))
axes.yaxis.set_ticks_position('left')
axes.spines['left'].set_position(('axes', -0.05))
axes.tick_params(axis='x', direction='out')
axes.tick_params(axis='y', direction='out')
What can I do to avoid my markers being cut at the borders?
You have to turn off clipping by adding clip_on=False
to your plot command:
import numpy as np
import matplotlib.pyplot as plt
plt.plot(range(10), marker='o', ms=20, clip_on=False)
axes = plt.gca()
axes.spines['right'].set_color('none')
axes.spines['top'].set_color('none')
axes.xaxis.set_ticks_position('bottom')
axes.spines['bottom'].set_position(('axes', -0.05))
axes.yaxis.set_ticks_position('left')
axes.spines['left'].set_position(('axes', -0.05))
axes.tick_params(axis='x', direction='out')
axes.tick_params(axis='y', direction='out')
plt.show()
which produces:
from pylab import *
plot(range(10), marker='o', ms=20)
#customize axes
axes = gca()
axes.spines['right'].set_color('none')
axes.spines['top'].set_color('none')
axes.xaxis.set_ticks_position('bottom')
axes.spines['bottom'].set_position(('axes', -0.05))
axes.yaxis.set_ticks_position('left')
axes.spines['left'].set_position(('axes', -0.05))
axes.tick_params(axis='x', direction='out')
axes.tick_params(axis='y', direction='out')
axes.spines['bottom'].set_smart_bounds(True)
axes.spines['left'].set_smart_bounds(True)
axes.set_xlim(-0.5, 9.5)
axes.set_ylim(-0.5, 9.5)
axes.set_xticks(range(10))
axes.set_yticks(range(10))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With