selfteaching / selfteaching/selfteaching-python-camp
Day13 无法返回统计图表
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 875
- PR merge metrics
- No merged PRs in 30d
Description
@yjz111 程序写好后运行提示“Unused variable 'fig'。matplotlib和numpy已正常安装。程序可以运行,运行后可以正确扫码登陆。但是发动链接后无法返回图标,求教,程序附下:
from mymodule import stats_word
import requests
from pyquery import PyQuery
from wxpy import *
bot=Bot()
my_friend=bot.friends().search('王小桐')
@bot.register(my_friend,SHARING)
def reply_my_friend(msg):
response=requests.get(msg.url)
document=PyQuery(response.text)
content=document('#js_content').text()
reply1=dict(stats_word.stats_txt(content,10))
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(19680801)
plt.rcdefaults()
fig=plt.figure()
fig,ax=plt.subplots()
word=[]
frequency=[]
for i in reply1:
word.append(i)
frequency.append(reply1[i])
y_pos=np.arange(len(word))
error=np.random.rand(len(word))
plt.rcParams['font.sans-serif'] = ['SimHei']
ax.barh(y_pos,xerr=error,align='center',color='green',ecolor='black')
ax.set_yticks(y_pos)
ax.set_yticklabels(word)
ax.invert_yaxis()
ax.set_xlabel('词语出现次数')
ax.set_title('词语统计')
plt.savefig('words_frequency.png')
msg.reply_image('words_frequency.png')
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 by running the Python snippet from the issue and inspect the flow from stats_word.stats_txt through matplotlib figure creation and plt.savefig('words_frequency.png'). Verify whether the generated image is returned by msg.reply_image('words_frequency.png'); done means the chart is produced and sent after a shared link is received.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, numpy, 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