반응형
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
def ww(self):#wrongwords text file
with open("wrongWords.txt") as file:
array1 = []
array2 = []
for element in file:
array1.append(element)
x=array1[0]
s = x.replace(')(', '),(') #removes the quote marks from csv file
print(s)
my_list = ast.literal_eval(s)
print(my_list)
my_dict = {}
for item in my_list:
my_dict[item[2]] = my_dict.get(item[2], 0) + 1
plt.bar(range(len(my_dict)), my_dict.values(), align='center')
plt.xticks(range(len(my_dict)), my_dict.keys())
plt.show()
해결 방법
교체 시도
plt.bar(range(len(my_dict)), my_dict.values(), align='center')
와
plt.figure(figsize=(20, 3)) # width:20, height:3
plt.bar(range(len(my_dict)), my_dict.values(), align='edge', width=0.3)
참조 페이지 https://stackoverflow.com/questions/40575067
반응형
'파이썬' 카테고리의 다른 글
파이썬 Python 3에서 URL 인코딩하는 방법은 무엇입니까? (0) | 2020.10.26 |
---|---|
파이썬 Openpyxl 인덱스로 워크 시트에서 행을 가져 오는 방법 (0) | 2020.10.26 |
파이썬 오류 발생-AttributeError : subprocess.run ([ "ls", "-l"])을 실행하는 동안 'module'개체에 'run'속성이 없습니다. (0) | 2020.10.26 |
파이썬 TypeError : 'int'개체는 구독 할 수 없습니다. (0) | 2020.10.26 |
파이썬 목록으로 Pandas 데이터 프레임 열 선택 (0) | 2020.10.26 |
댓글