#饼图
from pyecharts.charts import Pie
from pyecharts import options as opts
# 数据
cate = t1['布局'].tolist()
data1 =t1['房源数'].tolist()
pie = (Pie()
.add('房源数', [list(z) for z in zip(cate, data1)],
radius=["30%", "75%"],
rosetype="radius")
.set_global_opts(title_opts=opts.TitleOpts(title="户型分布", subtitle=""))
.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {d}%"))
)
pie.render_notebook()
组合图
#组合图
from pyecharts.charts import Bar,Line
from pyecharts import options as opts
# 数据
cate =t3['行政区'].tolist()
data1 = t3['年份'].tolist()
data2 = t3['总楼层'].tolist()
# 1.x版本支持链式调用
line = (Line()
.add_xaxis(cate)
.add_yaxis('建成年份', data1)
.extend_axis(
yaxis=opts.AxisOpts(
axislabel_opts=opts.LabelOpts(formatter="{value}层"), interval=2
))
.set_global_opts(title_opts=opts.TitleOpts(title="北京市各区二手房建成年份和总楼层(中位数)", subtitle=""),\
xaxis_opts=opts.AxisOpts(axislabel_opts={"rotate":45}),\
yaxis_opts=opts.AxisOpts(is_show=True,name="",min_=1990,max_=2023,is_inverse=False, axislabel_opts=opts.LabelOpts(formatter="{value}年"), interval=1))
)
bar = Bar()
bar.add_xaxis(cate).add_yaxis("总楼层", data2, yaxis_index=1)
line.overlap(bar)
line.render_notebook()
2024-1-24 文章目录 [2865. 美丽塔 I](https://leetcode.cn/problems/beautiful-towers-i/) 2865. 美丽塔 I 初始化变量 ans 为0,用于记录最大的和值。获取整数列表的长度,保存到变量 n 中。使用一个循环遍历列表中的每个位置,从0到n-1。在循…