0

I am trying to read data from a txt file containing 200 values and then trying to plot a histogram based on the data. However, there are too many values on the xticks, and I do not know how to fix this.
My code:

import math
import numpy as np
import matplotlib.pyplot as plt

f=open('LedData.rtf',"r")
lines=f.readlines()
result=[]
for x in lines:
    result.append(x.split(',')[1])
f.close()

plt.hist(result)
plt.xticks(rotation = 'vertical')
plt.show

Histogram : Here is an image for reference.

Thanks for any help.

bluevulture
  • 422
  • 4
  • 16
  • You said txt file but you are opening a rtf file! – raspiduino May 19 '21 at 02:53
  • Yes, @raspiduino is right. How could you do that? Either way, [here's a solution](https://stackoverflow.com/a/13418954/9997212) for your problem. – enzo May 19 '21 at 02:58

0 Answers0