astha
astha

Reputation: 613

How to mark spacial tick mark in matplotlib and custom the gridlines

My x-axis data starts from 100 to 1000 in step of 200. I want the x-axis tick marks as

100 200 400 600 800 1000.

Is there workaround to add the 100 at the start of x-axis?

Upvotes: 0

Views: 47

Answers (1)

Andrei
Andrei

Reputation: 481

import numpy as np
import matplotlib.pyplot as plt

x=np.arange(100,1001,20)
fig,ax=plt.subplots()
ax.plot(x,x)

#create tick positions
tp=np.arange(0,1001,200)
tp[0]=100

ax.xaxis.set_ticks(tp)
fig.show()

enter image description here

Upvotes: 1

Related Questions