selfteaching / selfteaching/selfteaching-python-camp
Day13 作业在最后输出图表时报错libpng warning: iCCP: known incorrect sRGB profile报错
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 875
- PR merge metrics
- No merged PRs in 30d
Description
以下是我的代码,经过测试,如果不进行微信登、接受信息的过程,单纯只是统计网页信息,都一切正常,能够输出正确的图表统计结果,但连起来就不行了,请教高手!
from wxpy import *
bot = Bot()
my_friend = bot.friends()
@bot.register(my_friend,SHARING)
def auto_reply(msg):
text = msg.url
print(text)
import requests
response = requests.get(text)
# 以上通过requests请求文章链接,获取网页内容
from pyquery import PyQuery
document = PyQuery(response.text)
content = document('#js_content').text() # 将网页内容提取为一个字符串文本作为输入
print(content)
import mymodule.stats_word
try:
if not isinstance(content,str):
raise ValueError()
except ValueError:
print('输入的不是文本格式,请重新输入:')
dic = mymodule.stats_word.stats_text_cn(content) # 调用函数进行分词并统计词频
dic = dict(dic)
import matplotlib.pyplot
import numpy
# Fixing random state for reproducibility
numpy.random.seed(19680801)
matplotlib.pyplot.rcdefaults()
fig, ax = matplotlib.pyplot.subplots()
# Example data
word = []
frequency = []
for i in dic:
word.append(i)
frequency.append(dic[i])
y_pos = numpy.arange(len(word))
error = numpy.random.rand(len(word))
ax.barh(y_pos, frequency, xerr=error, align='center',
color='green', ecolor='black')
ax.set_yticks(y_pos)
ax.set_yticklabels(word)
ax.invert_yaxis() # labels read top-to-bottom
ax.set_xlabel('词语出现次数')
ax.set_title('你刚才所发文章的词频统计')
return matplotlib.pyplot.show()
embed()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python script in the issue, focusing on the wxpy message callback, matplotlib plotting code, and the matplotlib.pyplot.show() call. Reproduce the complete flow and the plotting-only flow, then confirm whether the libpng iCCP warning prevents the chart from being displayed; no repository file or test is named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100