Reputation: 133
Is it possible to make a plot with slanted tick marks in Python3 with MatPlotLib. Slanted tick marks not tick mark labels. I have found many ways to slant the tick mark labels but no way to slant the tick mark itself. If it is possible could you please show an example.
My boss says that if you use slanted tick mark labels the tick mark itself must be slanted.
Upvotes: 0
Views: 196
Reputation: 39042
AFAIK, there is no such option to rotate the tick-marks unlike the tick labels. However, I came up with this crude solution that works for rotated ticks inside the figure.
I am here basically plotting small, slanted lines after hiding the real ticks. This is inspired from broken axis documentation. You can adapt it yourself for the y-axis as well.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(range(5))
ax.tick_params(axis='x', length=0, labelsize=20)
d = .1 # how big to make the diagonal lines in absolute coordinates
y_low = -0.5
for i in range(5):
ax.plot((i-d,i+d), (y_low-d,y_low+d), color='k')
ax.set_ylim(y_low, None)
plt.show()
Upvotes: 1