python词云图无法显示中文
import pandas as pd
from collections import Counter
from wordcloud import WordCloud
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
plt.rcParams['font.family'] = ['sans-serif']
plt.rcParams['font.sans-serif'] = ['SimHei']
keywords = []
for desc in df['type']:
words = desc.split()
keywords.extend(words)
keyword_counts = Counter(keywords)
wordcloud = WordCloud(width=400, height=200).generate_from_frequencies(keyword_counts)
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud, interpolation='bilinear',)
plt.axis('off')
plt.show()