matplotlib

《大秦赋》最近很火!于是我用Python抓取了“相关数据”,发现了这些秘密......

给你一囗甜甜゛ 提交于 2021-01-24 13:05:47
↑ 关注 + 星标 ,每天学Python新技能 后台回复【 大礼包 】送你Python自学大礼包 前言 最近,最火的电视剧莫过于《大秦赋了》,自12月1日开播后,收获了不错的口碑。然而随着电视剧的跟新,该剧在网上引起了 激烈的讨论 ,不仅口碑急剧下滑,颇有 高开低走的趋势 ,同时该剧的评分也由最初的8.9分,下降到了现在的6.5分。 虽然我还没有看过这个新剧,但是对于小伙伴们讨论的内容,却颇有兴趣(主要还是大家老是讨 论这个剧)。因此, 我用Python爬取了《大秦赋》的相关数据 ,进行了一波分析。 数据爬取 巧妇难为无米之炊,做数据分析之前最重要的就是 “数据获取” 。于是,我准备用Python爬取豆瓣上的 短评数据 以及一些 评论时间信息 、 评价星级信息 。 关于数据的爬取主要说以下几个内容: 1) 关于翻页操作 第一页: https://movie.douban.com/subject/ 26413293 /comments?status=P 第二页: https://movie.douban.com/subject/ 26413293 /comments?start= 20 &limit= 20 &status=P&sort=new_score 第三页: https://movie.douban.com/subject/ 26413293 /comments?start=

Dynamic labels in matplotlib stacked area chart

浪尽此生 提交于 2021-01-24 09:40:07
问题 I'm working with a stacked area plot created by pandas. The screenshots shows one such typical plot (labels are deliberatly not shown): The relevant code producing this plot is fig, axes = plt.subplots(nrows=2, ncols=1) coredata = nonzero.loc[:, nonzero.columns != 'Busy'].plot.area(figsize=(9, 8), ax=axes[0], colormap='jet') where nonzero is a larger dataframe. The issue is that there are too many columns leading to a crowded legend. Instead of moving the legend out of the picture I'd like to

Increase size of symbols in the matplotlib legend?

人盡茶涼 提交于 2021-01-24 07:16:37
问题 I draw a plot with markers like so: plt.scatter(xs1, ys1, s=12, linewidths=0, marker='o', label='hello') plt.scatter(xs2, ys2, s=12, linewidths=0, marker='x', label='hello') this produces the right size in the graph, but the symbols are hardly intelligible in the legend. How can I increase the size of the symbols in the legend ? 回答1: I found the solution in matplotlib.pyplot.legend. The legend takes an attribue 'markerscale'. plt.legend(loc='best',markerscale=2) 来源: https://stackoverflow.com

Increase size of symbols in the matplotlib legend?

亡梦爱人 提交于 2021-01-24 07:14:11
问题 I draw a plot with markers like so: plt.scatter(xs1, ys1, s=12, linewidths=0, marker='o', label='hello') plt.scatter(xs2, ys2, s=12, linewidths=0, marker='x', label='hello') this produces the right size in the graph, but the symbols are hardly intelligible in the legend. How can I increase the size of the symbols in the legend ? 回答1: I found the solution in matplotlib.pyplot.legend. The legend takes an attribue 'markerscale'. plt.legend(loc='best',markerscale=2) 来源: https://stackoverflow.com

How to divide y-ticks by a certain number in matplotlib?

不想你离开。 提交于 2021-01-23 06:37:29
问题 I have a simple matplotlib histogram and I need to divide ylabels to a certain number. For example I have 100 200 and 300 while I need to have 1,2, and 3. Any suggestion? Here is my code: import numpy import matplotlib # Turn off DISPLAY matplotlib.use('Agg') import pylab # Figure aspect ratio, font size, and quality matplotlib.pyplot.figure(figsize=(100,50),dpi=400) matplotlib.rcParams.update({'font.size': 150}) matplotlib.rcParams['xtick.major.pad']='68' matplotlib.rcParams['ytick.major.pad

How to divide y-ticks by a certain number in matplotlib?

Deadly 提交于 2021-01-23 06:36:31
问题 I have a simple matplotlib histogram and I need to divide ylabels to a certain number. For example I have 100 200 and 300 while I need to have 1,2, and 3. Any suggestion? Here is my code: import numpy import matplotlib # Turn off DISPLAY matplotlib.use('Agg') import pylab # Figure aspect ratio, font size, and quality matplotlib.pyplot.figure(figsize=(100,50),dpi=400) matplotlib.rcParams.update({'font.size': 150}) matplotlib.rcParams['xtick.major.pad']='68' matplotlib.rcParams['ytick.major.pad

Get viewing/camera angles in Matplotlib 3D plot?

混江龙づ霸主 提交于 2021-01-23 05:41:48
问题 How can I save the viewing angle / camera position when I've rotated my Matplotlib 3D plot with my mouse, and use those values to set the viewing angle programmatically the next time I run my script? 回答1: TL;DR The viewing angles are stored in the axis-object of the figure under the names elev and azim , and the view can be set with plt.gca().view_init(elev, azim) . Elaborate answer and example Import libraries and generate data to plot: import matplotlib as mpl # noqa from mpl_toolkits

Get viewing/camera angles in Matplotlib 3D plot?

风格不统一 提交于 2021-01-23 05:39:46
问题 How can I save the viewing angle / camera position when I've rotated my Matplotlib 3D plot with my mouse, and use those values to set the viewing angle programmatically the next time I run my script? 回答1: TL;DR The viewing angles are stored in the axis-object of the figure under the names elev and azim , and the view can be set with plt.gca().view_init(elev, azim) . Elaborate answer and example Import libraries and generate data to plot: import matplotlib as mpl # noqa from mpl_toolkits

一图搞定Matplotlib!

旧巷老猫 提交于 2021-01-22 18:48:26
今天给大家分享一位GitHub大神制作的 Matplotlib cheat sheet, 直接看图 ⬇️ 那么我们来看看,这张图里到底藏了哪些宝贝。 01 图形类型 02 图例配置 03 颜色选项 04 线条相关 05 标记项配置 06 坐标轴相关配置 07 更多的图形 08 其他配置 使用方法我想也不用多说,下载设为壁纸或者打印贴在电脑旁还是做成鼠标垫?总之哪里有Matplotlib哪里就有它! 原版高清大图,后台 回复 绘图 获取。 加入机器学习 微信群 请后台回复 【入群】 推荐阅读: Python处理大数据,推荐4款加速神器 欢迎挑战!14个数据分析和机器学习项目!附数据集 复旦大学机器学习、深度学习视频公开课,附PDF课件下载 喜欢文章,点个 在看 本文分享自微信公众号 - 机器学习算法与Python实战(tjxj666)。 如有侵权,请联系 support@oschina.cn 删除。 本文参与“ OSC源创计划 ”,欢迎正在阅读的你也加入,一起分享。 来源: oschina 链接: https://my.oschina.net/u/2324223/blog/4424711

mayavi 3d object in matplotlib Axes3D

孤者浪人 提交于 2021-01-22 13:22:11
问题 I sometimes find myself frustrated with the lack of certain rendering features in matplotlib's mplot3d. In most of these cases, I do find that I can get what I want in mayavi, but still the matplotlib 3d axes are preferable, if only for aesthetics, like LaTeX-ified labels and visual consistency with my other figures. My question here is about the obvious hack: is it possible to draw some 3d object (a surface or 3d scatter plot or whatever) in mayavi without axes, export that image, then place