'x-axis get over written in matplot

I am working on my dataset and I have to plot the cdf of it. I already did but due to large number of data the x-axis showing some overwritten values. Could anyone help me in this regard. my code is

import csv
import os
import numpy as np
import matplotlib.pyplot as plt
from collections import Counter
import collection

x = []
y=[]
row=[]
with open('SCPS-ADAPTIVE-1e8.csv', 'r') as file:
   reader = csv.reader(file)
   for row in reader:
      y.append(row[1])
N=len(y)
data = np.sort(y)
P = np.arange(N) / float(N)
plt.plot(data, P, marker='o')
plt.show (

plot



Solution 1:[1]

You didn't provide data so we cannot replicate your chart. However, this is what I would try:

# increase or decrease this variable to satisfy your needs
num_labels = 30
ticks = [t for t in range(N) if t % num_labels == 0]
labels = [l for i, l in enumerate(data) if i % num_labels == 0]
plt.xticks(ticks, labels)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Davide_sd