0
点赞
收藏
分享

微信扫一扫

使用plotly.express绘制散点图

青鸾惊鸿 2022-04-13 阅读 60
python
import plotly.express as px

gapminder = px.data.gapminder()
gapminder.head()

读取前5行数据
在这里插入图片描述

fig = px.scatter(data_frame=gapminder,
				 x='gdpPercap',
				 y='lifeExp',
				 color='continent',
				 animation_frame='year',
				 log_x=True,
				 hover_name='country',
				 title='人均寿命和GDP. 1952 - 2007',
				 labels={'gdpPercap': '人均GDP',
						 'lifeExp': '平均寿命'},
				 size='pop',
				 size_max=90,
				 facet_col='continent',
				 range_y=[20, 100],
				 height=600,
				 width=1300)

fig.show()

图像显示为:
在这里插入图片描述

举报

相关推荐

0 条评论