pyecharts-直角坐标系图标
本项目整理了目前
pyecharts
支持的所有图表以及基础配置项~所有代码均基于
Pyecharts v1.7.1
版本,均已全部运行通过
from pyecharts.charts import * from pyecharts.components import Table from pyecharts import options as opts from pyecharts.commons.utils import JsCode import random import datetime
资源引用
Pyecharts
图表生成需要一些静态资源文件,通过下面代码更改为kesci提供的资源,提高加载速度~
from pyecharts.globals import CurrentConfig CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
所有图表¶
囊括了目前Pyecharts中支持的所有图表,所有示例均为默认配置~
直角坐标系图表¶
直方图
# 虚假数据 x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu'] y_data = [123, 153, 89, 107, 98, 23] bar = (Bar() .add_xaxis(x_data) .add_yaxis('', y_data) ) bar.render_notebook()
折线图
# 虚假数据 x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu'] y_data = [123, 153, 89, 107, 98, 23] line = (Line() .add_xaxis(x_data) .add_yaxis('', y_data) ) line.render_notebook()
箱形图
# 虚假数据 x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu'] y_data = [[random.randint(100, 200) for i in range(10)] for item in x_data] Box = Boxplot() Box.add_xaxis(x_data) Box.add_yaxis("", Box.prepare_data(y_data)) Box.render_notebook()
散点图
# 虚假数据 x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu'] y_data = [123, 153, 89, 107, 98, 23] scatter = (Scatter() .add_xaxis(x_data) .add_yaxis('', y_data) ) scatter.render_notebook()
带涟漪效果散点图
# 虚假数据
x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data = [123, 153, 89, 107, 98, 23]
effectScatter = (EffectScatter()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
effectScatter.render_notebook()
k线图
# 虚假数据 date_list = ["2020/4/{}".format(i + 1) for i in range(30)] y_data = [ [2320.26, 2320.26, 2287.3, 2362.94], [2300, 2291.3, 2288.26, 2308.38], [2295.35, 2346.5, 2295.35, 2345.92], [2347.22, 2358.98, 2337.35, 2363.8], [2360.75, 2382.48, 2347.89, 2383.76], [2383.43, 2385.42, 2371.23, 2391.82], [2377.41, 2419.02, 2369.57, 2421.15], [2425.92, 2428.15, 2417.58, 2440.38], [2411, 2433.13, 2403.3, 2437.42], [2432.68, 2334.48, 2427.7, 2441.73], [2430.69, 2418.53, 2394.22, 2433.89], [2416.62, 2432.4, 2414.4, 2443.03], [2441.91, 2421.56, 2418.43, 2444.8], [2420.26, 2382.91, 2373.53, 2427.07], [2383.49, 2397.18, 2370.61, 2397.94], [2378.82, 2325.95, 2309.17, 2378.82], [2322.94, 2314.16, 2308.76, 2330.88], [2320.62, 2325.82, 2315.01, 2338.78], [2313.74, 2293.34, 2289.89, 2340.71], [2297.77, 2313.22, 2292.03, 2324.63], [2322.32, 2365.59, 2308.92, 2366.16], [2364.54, 2359.51, 2330.86, 2369.65], [2332.08, 2273.4, 2259.25, 2333.54], [2274.81, 2326.31, 2270.1, 2328.14], [2333.61, 2347.18, 2321.6, 2351.44], [2340.44, 2324.29, 2304.27, 2352.02], [2326.42, 2318.61, 2314.59, 2333.67], [2314.68, 2310.59, 2296.58, 2320.96], [2309.16, 2286.6, 2264.83, 2333.29], [2282.17, 2263.97, 2253.25, 2286.33], ] kline = (Kline() .add_xaxis(date_list) .add_yaxis('', y_data) ) kline.render_notebook()
热力图
# 虚假数据 data = [[i, j, random.randint(0, 100)] for i in range(24) for j in range(7)] hour_list = [str(i) for i in range(24)] week_list = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'] heat = (HeatMap() .add_xaxis(hour_list) .add_yaxis("", week_list, data) ) heat.render_notebook()
象型图
# 虚假数据 x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu'] y_data = [123, 153, 89, 107, 98, 23] pictorialBar = (PictorialBar() .add_xaxis(x_data) .add_yaxis('', y_data) ) pictorialBar.render_notebook()
层叠图
# 虚假数据 x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu'] y_data_bar = [123, 153, 89, 107, 98, 23] y_data_line = [153, 107, 23, 89, 123, 107] bar = (Bar() .add_xaxis(x_data) .add_yaxis('', y_data_bar) ) line = (Line() .add_xaxis(x_data) .add_yaxis('', y_data_line) ) overlap = bar.overlap(line) overlap.render_notebook()
天道酬勤 循序渐进 技压群雄