如何使每个直方图箱显示每个动作/事件/项目的频率?

时间:2015-06-16 00:26:43

标签: python-3.x matplotlib histogram

我想绘制一个描绘不同时间段各种动作频率的组织图。我想把动作的出现时间间隔为10分钟。

Traceback (most recent call last):
  File "C:/Users/Chad LaFarge/PycharmProjects/APIAccess/YouTubeAPI.py", line 33, in <module>
    print(respData)
  File "C:\Python34\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u25bb' in position 11737: character maps to <undefined>

在上面的每个动作都有相应的时间。现在,如果我执行以下操作,我会得到显示每10分钟间隔时间频率的组织图。所以这告诉我每个垃圾箱中发生了多少次操作,但没有告诉我发生了哪些操作。

binwidth = 10*60 #10 minutes
times = array([  1.43431325e+09,   1.43431325e+09,   1.43431329e+09,
     1.43431330e+09,   1.43431333e+09,   1.43431334e+09,
     1.43431345e+09,   1.43431346e+09,   1.43431346e+09,
     1.43431346e+09,   1.43431349e+09,   1.43431350e+09,
     1.43431350e+09,   1.43431351e+09,   1.43431354e+09,
     1.43431354e+09,   1.43431354e+09,   1.43431355e+09,
     1.43431355e+09,   1.43431356e+09,   1.43431356e+09,
     1.43431356e+09,   1.43431360e+09,   1.43431360e+09,
     1.43431366e+09,   1.43431366e+09,   1.43431378e+09,
     1.43431378e+09,   1.43431385e+09,   1.43431385e+09,
     1.43431386e+09,   1.43431386e+09,   1.43431389e+09,
     1.43431390e+09,   1.43431390e+09,   1.43431390e+09,
     1.43431394e+09,   1.43431394e+09,   1.43431398e+09,
     1.43431399e+09,   1.43431404e+09,   1.43431404e+09,
     1.43431422e+09,   1.43431422e+09,   1.43431423e+09,
     1.43431423e+09,   1.43431424e+09,   1.43431424e+09,
     1.43431425e+09,   1.43431425e+09,   1.43431425e+09,
     1.43431425e+09,   1.43431426e+09,   1.43431426e+09,
     1.43431426e+09,   1.43431427e+09,   1.43431427e+09,
     1.43431428e+09,   1.43431428e+09,   1.43431428e+09,
     1.43431430e+09,   1.43431430e+09,   1.43431440e+09,
     1.43431440e+09,   1.43431475e+09,   1.43431475e+09,
     1.43431479e+09,   1.43431479e+09,   1.43431482e+09,
     1.43431482e+09,   1.43431484e+09,   1.43431485e+09,
     1.43431515e+09,   1.43431515e+09,   1.43431566e+09,
     1.43431567e+09,   1.43431568e+09,   1.43431568e+09,
     1.43431570e+09,   1.43431570e+09,   1.43431575e+09,
     1.43431576e+09,   1.43431577e+09,   1.43431577e+09,
     1.43431688e+09,   1.43431689e+09])

actions = array(['entry', 'exit', 'entry', 'exit', 'entry', 'exit', 'entry', 'exit',
   'entry', 'exit', 'entry', 'exit', 'entry', 'exit', 'entry', 'exit',
   'entry', 'exit', 'entry', 'exit', 'entry', 'exit', 'entry', 'exit',
   'entry', 'exit', 'entry', 'exit', 'entry', 'exit', 'entry', 'exit',
   'entry', 'exit', 'entry', 'exit', 'entry', 'exit', 'entry', 'exit',
   'entry', 'exit', 'entry', 'check+', 'reward', 'reward', 'reward',
   'reward', 'reward', 'complete', 'exit', 'entry', 'check+',
   'reward', 'reward', 'reward', 'reward', 'reward', 'complete',
   'exit', 'entry', 'exit', 'entry', 'exit', 'entry', 'exit', 'entry',
   'exit', 'entry', 'exit', 'entry', 'exit', 'entry', 'exit', 'entry',
   'exit', 'entry', 'exit', 'entry', 'exit', 'entry', 'exit', 'entry',
   'exit', 'entry', 'exit'], 
  dtype='|S9')

Histrogram

如何让每个垃圾箱显示每个动作的频率?

1 个答案:

答案 0 :(得分:1)

包含您的数据,

2015-06-15T20:13:20.488264+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-06-15T20:13:20.488268+00:00 app[web.1]:     at Function.Module.runMain (module.js:501:10)
2015-06-15T20:13:20.488265+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-06-15T20:13:21.385482+00:00 heroku[web.1]: Process exited with status 1
2015-06-15T20:13:21.421482+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T20:13:33.850256+00:00 heroku[api]: Scale to web=1 by c.kazbour@gmail.com
2015-06-15T20:13:42.056575+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=cbef7e0e-24cb-45f1-9934-7a326a514ed4 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:13:48.199162+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=7ba21844-6623-4d9c-af76-ffa60cad4fbd fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:26:58.464510+00:00 heroku[api]: Deploy 36f1770 by c.kazbour@gmail.com
2015-06-15T20:26:58.464510+00:00 heroku[api]: Release v4 created by c.kazbour@gmail.com
2015-06-15T20:26:58.548710+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T20:26:58.512202+00:00 heroku[slug-compiler]: Slug compilation started
2015-06-15T20:26:58.512230+00:00 heroku[slug-compiler]: Slug compilation finished
2015-06-15T20:27:02.685211+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T20:27:04.742124+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T20:27:04.742151+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T20:27:05.295237+00:00 app[web.1]: module.js:338
2015-06-15T20:27:05.295241+00:00 app[web.1]:     throw err;
2015-06-15T20:27:05.295242+00:00 app[web.1]:           ^
2015-06-15T20:27:05.295244+00:00 app[web.1]: Error: Cannot find module 'express-session'
2015-06-15T20:27:05.295247+00:00 app[web.1]:     at Function.Module._load (module.js:278:25)
2015-06-15T20:27:05.295246+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:336:15)
2015-06-15T20:27:05.295248+00:00 app[web.1]:     at Module.require (module.js:365:17)
2015-06-15T20:27:05.295250+00:00 app[web.1]:     at require (module.js:384:17)
2015-06-15T20:27:05.295251+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:11:15)
2015-06-15T20:27:05.295253+00:00 app[web.1]:     at Module._compile (module.js:460:26)
2015-06-15T20:27:05.295255+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:478:10)
2015-06-15T20:27:05.295257+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-06-15T20:27:05.295256+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-06-15T20:27:05.295259+00:00 app[web.1]:     at Function.Module.runMain (module.js:501:10)
2015-06-15T20:27:06.155893+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T20:27:06.156698+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T20:27:06.140225+00:00 heroku[web.1]: Process exited with status 1
2015-06-15T20:27:09.292073+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T20:27:11.100911+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T20:27:11.100933+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T20:27:11.975393+00:00 app[web.1]: module.js:338
2015-06-15T20:27:11.975397+00:00 app[web.1]:     throw err;
2015-06-15T20:27:11.975399+00:00 app[web.1]:           ^
2015-06-15T20:27:11.975401+00:00 app[web.1]: Error: Cannot find module 'express-session'
2015-06-15T20:27:11.975402+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:336:15)
2015-06-15T20:27:11.975404+00:00 app[web.1]:     at Function.Module._load (module.js:278:25)
2015-06-15T20:27:11.975405+00:00 app[web.1]:     at Module.require (module.js:365:17)
2015-06-15T20:27:11.975408+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:11:15)
2015-06-15T20:27:11.975407+00:00 app[web.1]:     at require (module.js:384:17)
2015-06-15T20:27:11.975410+00:00 app[web.1]:     at Module._compile (module.js:460:26)
2015-06-15T20:27:11.975411+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:478:10)
2015-06-15T20:27:11.975412+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-06-15T20:27:11.975414+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-06-15T20:27:11.975415+00:00 app[web.1]:     at Function.Module.runMain (module.js:501:10)
2015-06-15T20:27:13.067329+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T20:27:13.052249+00:00 heroku[web.1]: Process exited with status 1
2015-06-15T20:27:19.506077+00:00 heroku[api]: Scale to web=1 by c.kazbour@gmail.com
2015-06-15T20:27:46.543780+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=3df4bc96-feb7-48c6-a52b-ded903ae154e fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:34:06.988969+00:00 heroku[slug-compiler]: Slug compilation started
2015-06-15T20:34:06.988997+00:00 heroku[slug-compiler]: Slug compilation finished
2015-06-15T20:34:06.911574+00:00 heroku[api]: Deploy d8ce9d8 by c.kazbour@gmail.com
2015-06-15T20:34:06.911574+00:00 heroku[api]: Release v5 created by c.kazbour@gmail.com
2015-06-15T20:34:07.186442+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T20:34:09.816487+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T20:34:11.760020+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T20:34:11.760047+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T20:34:12.637513+00:00 app[web.1]: I'm listening
2015-06-15T20:34:27.737044+00:00 heroku[api]: Scale to web=1 by c.kazbour@gmail.com
2015-06-15T20:35:10.211701+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-06-15T20:35:10.211701+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-06-15T20:35:11.059387+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T20:35:11.047891+00:00 heroku[web.1]: Process exited with status 137
2015-06-15T20:35:49.365371+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=596720e4-470d-4c1b-9beb-88830c2530b4 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:35:54.100625+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=3304c0b0-4ea8-4b4c-9b15-68018303143a fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:35:59.738039+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=f0c96f6c-e017-443b-b3fc-c470ea172b09 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:35:56.928372+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=bd37d2d7-4e40-4a83-ae4c-c4bb8d77ebab fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:47:13.464465+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=11dae041-9755-46f3-8120-62185021f166 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T20:50:18.169656+00:00 heroku[api]: Starting process with command `bash` by c.kazbour@gmail.com
2015-06-15T20:50:21.182682+00:00 heroku[run.7063]: Awaiting client
2015-06-15T20:50:21.207522+00:00 heroku[run.7063]: Starting process with command `bash`
2015-06-15T20:50:21.498626+00:00 heroku[run.7063]: State changed from starting to up
2015-06-15T20:56:22.967959+00:00 heroku[run.7063]: Process exited with status 130
2015-06-15T20:56:22.982990+00:00 heroku[run.7063]: State changed from up to complete
2015-06-15T20:56:34.860491+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=03ab7279-9f54-47f3-bd78-66a1f8878f11 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-15T22:06:06.911203+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T22:06:09.190364+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T22:06:11.192311+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T22:06:11.192332+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T22:06:12.342276+00:00 app[web.1]: I'm listening
2015-06-15T22:07:09.670256+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-06-15T22:07:09.670341+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-06-15T22:07:10.700825+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-15T22:07:10.687467+00:00 heroku[web.1]: Process exited with status 137
2015-06-15T23:35:04.950903+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-15T23:35:10.538060+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-06-15T23:35:13.112171+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-06-15T23:35:13.120415+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-06-15T23:35:16.100005+00:00 app[web.1]: I'm listening
2015-06-15T23:36:10.835815+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-06-15T23:36:10.835815+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-06-15T23:36:11.797436+00:00 heroku[web.1]: Process exited with status 137
2015-06-15T23:36:11.815434+00:00 heroku[web.1]: State changed from starting to crashed
2015-06-16T00:28:50.659338+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=4412f0e2-1e68-4ec0-9a62-47c3f5151cbb fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-16T00:28:55.687612+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=b3487f82-36f7-4138-9247-30a8a45effd9 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=
2015-06-16T00:28:58.049747+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=simplifly.herokuapp.com request_id=69e2ddf4-9c28-42f5-8aec-47cf51bb4109 fwd="50.141.68.137" dyno= connect= service= status=503 bytes=

产生

enter image description here