真爱,请置顶或星标
![128868ac331802d7363798fde715ea91.png](https://i-blog.csdnimg.cn/blog_migrate/546e909f258708a550eaeb4e988478cc.png)
import seaborn as snsimport matplotlib.pyplot as plt
color_order = ['xkcd:cerulean', 'xkcd:ocean','xkcd:black','xkcd:royal purple','xkcd:royal purple', 'xkcd:navy blue','xkcd:powder blue', 'xkcd:light maroon', 'xkcd:lightish blue','xkcd:navy']
sns.barplot(x=top10.Team,
y=top10.Salary,
palette=color_order).set_title('Teams with Highest Median Salary')
plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
![87335f2dfc4a2ccde5db88dc2f2ff3e7.png](https://i-blog.csdnimg.cn/blog_migrate/3e95fbcb9db2fd5c6108e898e9715369.png)
import matplotlib.pyplot as pltimport scipy.stats as stats
#model2 is a regression model
log_resid = model2.predict(X_test)-y_test
stats.probplot(log_resid, dist="norm", plot=plt)
plt.title("Normal Q-Q plot")
plt.show()
![79be9dd0964c3878f5820b01fefc6314.png](https://i-blog.csdnimg.cn/blog_migrate/4ff3420ed363238e64f8f23a4f4c7f16.png)
#All Salaries
ggplot(data=df, aes(x=season_start, y=salary, colour=team)) +
geom_point() +
theme(legend.position="none") +
labs(title = 'Salary Over Time', x='Year', y='Salary ($)')
![ca8a59d83d891097734a6a9507e642ce.png](https://i-blog.csdnimg.cn/blog_migrate/926558b0a02b87c6c2b74be934f3ec84.jpeg)
import pandas as pdfrom bokeh.plotting import figurefrom bokeh.io import show
# is_masc is a one-hot encoded dataframe of responses to the question:
# "Do you identify as masculine?"
#Dataframe Prep
counts = is_masc.sum()
resps = is_masc.columns
#Bokeh
p2 = figure(title='Do You View Yourself As Masculine?',
x_axis_label='Response',
y_axis_label='Count',
x_range=list(resps))
p2.vbar(x=resps, top=counts, width=0.6, fill_color='red', line_color='black')
show(p2)
#Pandas
counts.plot(kind='bar')
![2ba7853316d9dc76037e6e8548d34e18.png](https://i-blog.csdnimg.cn/blog_migrate/76f5f3470756659b059d53a1aeafbba7.jpeg)
![5b0655a82ba3f2e439d1fc65ca35bf55.png](https://i-blog.csdnimg.cn/blog_migrate/06354d8297d4da275ffc0f195074a00d.png)
![d0b81bd9d78c313adc9b3bf679cb6ffa.png](https://i-blog.csdnimg.cn/blog_migrate/8792ebd97969d27c49c53975e2baf6fa.jpeg)
安装时要有 API 秘钥,还要注册,不是只用 pip 安装就可以;
Plotly 所绘制的数据和布局对象是独一无二的,但并不直观;
图片布局对我来说没有用(40 行代码毫无意义!)
你可以在 Plotly 网站和 Python 环境中编辑图片;
支持交互式图片和商业报表;
Plotly 与 Mapbox 合作,可以自定义地图;
很有潜力绘制优秀图形。
#plot 1 - barplot
# **note** - the layout lines do nothing and trip no errors
data = [go.Bar(x=team_ave_df.team,
y=team_ave_df.turnovers_per_mp)]
layout = go.Layout(
title=go.layout.Title(
text='Turnovers per Minute by Team',
xref='paper',
x=0
),
xaxis=go.layout.XAxis(
title = go.layout.xaxis.Title(
text='Team',
font=dict(
family='Courier New, monospace',
size=18,
color='#7f7f7f'
)
)
),
yaxis=go.layout.YAxis(
title = go.layout.yaxis.Title(
text='Average Turnovers/Minute',
font=dict(
family='Courier New, monospace',
size=18,
color='#7f7f7f'
)
)
),
autosize=True,
hovermode='closest')
py.iplot(figure_or_data=data, layout=layout, filename='jupyter-plot', sharing='public', fileopt='overwrite')
#plot 2 - attempt at a scatterplot
data = [go.Scatter(x=player_year.minutes_played,
y=player_year.salary,
marker=go.scatter.Marker(color='red',
size=3))]
layout = go.Layout(title="test",
xaxis=dict(title='why'),
yaxis=dict(title='plotly'))
py.iplot(figure_or_data=data, layout=layout, filename='jupyter-plot2', sharing='public')
[Image: image.png]
![abd54906d6efb331ef06007224b7622d.png](https://i-blog.csdnimg.cn/blog_migrate/248b28f42eb4e7d81ad8321582569b21.png)
![d76bfee98a808030b0bc0cb183fd99c0.png](https://i-blog.csdnimg.cn/blog_migrate/18311f5faeb828d1cc2fdbf8b324433b.jpeg)
![a60b0490773fa44c3adc4545c5ac2124.png](https://i-blog.csdnimg.cn/blog_migrate/33d49bc14eb30788f56afc25bbab06a5.jpeg)
实例化图片;
用图片目标属性格式化;
用 figure.add() 将数据添加到图片中。
![bfb228548124ea8c75b4f3d5a0b9ca76.png](https://i-blog.csdnimg.cn/blog_migrate/bb0ab407dcb90e2539c6150faee9fdc6.jpeg)
![72c6d6280979339500581f8428e6d57e.png](https://i-blog.csdnimg.cn/blog_migrate/286f5796bbd83e3c82216c0f4c31c1d6.png)
options = {'node_color' : range(len(G)),'node_size' : 300,'width' : 1,'with_labels' : False,'cmap' : plt.cm.coolwarm
}
nx.draw(G, **options)
![951bb97eb02beb863c7e076ec4904ea0.png](https://i-blog.csdnimg.cn/blog_migrate/5218993547755e578ec62d49893a94a3.png)
import itertoolsimport networkx as nximport matplotlib.pyplot as plt
f = open('data/facebook/1684.circles', 'r')
circles = [line.split() for line in f]
f.close()
network = []for circ in circles:
cleaned = [int(val) for val in circ[1:]]
network.append(cleaned)
G = nx.Graph()for v in network:
G.add_nodes_from(v)
edges = [itertools.combinations(net,2) for net in network]for edge_group in edges:
G.add_edges_from(edge_group)
options = {'node_color' : 'lime','node_size' : 3,'width' : 1,'with_labels' : False,
}
nx.draw(G, **options)
![18d25757e8a300e3eb9ae0886fd97a76.png](https://i-blog.csdnimg.cn/blog_migrate/8eb4f2e2ba6fa6a3e7f3f1d992e2a13d.png)
推荐阅读:
Python基础专题👇
1、Python中的线程和进程
2、Python多线程实战
3、Python中数据深拷贝、浅拷贝
4、Python中的作用域
5、Python中的内存管理机制
Python爬虫和数据分析专题👇
1、Python爬取某站上海租房图片
2、Python爬取拉勾网数据并进行数据可视化
3、Python爬虫小白入门-爬取披头士乐队历年专辑封面-网易云音乐
4、Python动手分析天猫内衣售卖数据,得到你想知道的信息
5、Python抓取猫眼近10万条评论并分析电影《一出好戏》到底如何?
6、Python爬虫实战:利用scrapy,短短50行代码下载整站短视频
7、Python 通过采集两万条数据,对《无名之辈》影评分析
8、想不想知道充气娃娃到底什么感觉?来!我用Python告诉你
9、Python爬虫:动态爬取QQ说说并生成词云,分析朋友状况
10、Python + PyQt5 实现美剧爬虫可视工具
11、Python爬取批量获取高清壁纸
12、有趣的一个Python爬虫实例(爬取段子,笑话,情感句子)
13、Python爬虫获取电子书资源实战
14、面试官问我会用Python爬虫腾讯视频么?我是这样回复的...
15、18个Python爬虫实战案例(已开源)
16、Python爬虫44万条数据:如何成为网易云音乐评论区的网红段子手?
17、深夜,我用Python爬取了整个斗图网站,不服来斗
18、再推荐23个Python爬虫开源项目代码:微信、淘宝、豆瓣
19、我用Python爬了点你们需要的电影,这些电影真的很不错~
20、Python爬取抖音高颜值小姐姐视频
Python综合专题👇
1、使用 Python 进行微信好友分析
2、Python面试题37道(附答案)看完面试不愁了
3、Python 利用opencv去除图片水印
4、被女朋友三番两次拉黑后,我用 Python 写了个“舔狗”必备神器
5、昨晚家里停网后,我动了邪念用Python破解了隔壁小姐姐的wifi密码
6、东半球最强Python新手100天学习计划开源,这次再学不会算我输!
7、向Excel说再见,神级编辑器统一表格与Python
8、牛逼,竟然可以用 Python 操作 Word 文档,这么多的骚操作!
更多爬虫,关注“Python技术之巅”公号,后台回复:“爬虫实战”,获取独家整理的一份爬虫汇总。长按二维码识别关注分享Python&AI干货,点亮 在看