x 轴覆盖在 matplot 中

x-axis get over written in matplot

我正在处理我的数据集,我必须绘制它的 cdf。我已经做了,但由于大量数据,x 轴显示了一些被覆盖的值。任何人都可以在这方面帮助我。我的代码是

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 (

您没有提供数据,因此我们无法复制您的图表。然而,这就是我要尝试的:

# 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)