欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解如何使用Pyecharts制作Map3D

 更新時(shí)間:2021年06月20日 14:56:24   作者:Mr數(shù)據(jù)楊  
本文基于 Python3 的 Pyecharts 制作 Map3D(三維地圖) 時(shí)需要使用的設(shè)置參數(shù)和常用模板案例,使用 Pyecharts 進(jìn)行數(shù)據(jù)可視化時(shí)可提供直觀、交互豐富、可高度個(gè)性化定制的數(shù)據(jù)可視化圖表。案例中的代碼內(nèi)容基于 Pyecharts 1.x 版本,需要的朋友可以參考下

基本設(shè)置

class Map3D(
    # 初始化配置項(xiàng),參考 `global_options.InitOpts`
    init_opts: opts.InitOpts = opts.InitOpts()
)

def add(
    # 系列名稱,用于 tooltip 的顯示,legend 的圖例篩選。
    series_name: str,

    # 數(shù)據(jù)項(xiàng) (坐標(biāo)點(diǎn)名稱,坐標(biāo)點(diǎn)值)
    data_pair: types.Sequence,

    # 疊加圖的類型(目前只支持 Bar3D,Line3D,Lines3D,Scatter3D)
    type_: ChartType = None,

    # 地圖類型,具體參考 pyecharts.datasets.map_filenames.json 文件
    maptype: str = "china",

    # 是否選中圖例
    is_selected: bool = True,

    # 是否顯示標(biāo)記圖形
    is_map_symbol_show: bool = True,

    # 使用的 grid3D 組件的索引。默認(rèn)使用第一個(gè) grid3D 組件。
    grid_3d_index: types.Numeric = 0,

    # 坐標(biāo)軸使用的 geo3D 組件的索引。默認(rèn)使用第一個(gè) geo3D 組件。
    geo_3d_index: types.Numeric = 0,

    # 坐標(biāo)軸使用的 globe 組件的索引。默認(rèn)使用第一個(gè) globe 組件。
    globe_index: types.Numeric = 0,

    # 僅在 bar3D 下起作用
    # 設(shè)置柱子的大小
    bar_size: types.Optional[types.Numeric] = None,

    # 僅在 bar3D 下起作用
    # 柱子的倒角尺寸。支持設(shè)置為從 0 到 1 的值。默認(rèn)為 0,即沒有倒角。
    bevel_size: types.Numeric = 0,

    # 僅在 bar3D 下起作用
    # 柱子倒角的光滑/圓潤度,數(shù)值越大越光滑/圓潤。
    bevel_smoothness: types.Numeric = 2,

    # 僅在 bar3D 下起作用
    # 柱狀圖堆疊,相同 stack 值的柱狀圖系列數(shù)據(jù)會(huì)有疊加。
    # 注意不同系列需要疊加的數(shù)據(jù)項(xiàng)在數(shù)組中的索引必須是一樣的。
    stack: types.Optional[str] = None,

    # 僅在 bar3D 下起作用
    # 最小柱子高度。
    min_height: types.Numeric = 2,

    # 僅在 Scatter3D 起作用;
    # 散點(diǎn)的形狀。默認(rèn)為圓形。
    # ECharts 提供的標(biāo)記類型包括 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none'
    # 可以通過 'path://' 將圖標(biāo)設(shè)置為任意的矢量路徑。
    # 這種方式相比于使用圖片的方式,不用擔(dān)心因?yàn)榭s放而產(chǎn)生鋸齒或模糊,而且可以設(shè)置為任意顏色。
    # 路徑圖形會(huì)自適應(yīng)調(diào)整為合適(如果是 symbol 的話就是 symbolSize)的大小。
    symbol: str = "circle",

    # 僅在 Scatter3D 起作用;
    # 標(biāo)記的大小,可以設(shè)置成諸如 10 這樣單一的數(shù)字,也可以用數(shù)組分開表示寬和高,例如 [20, 10] 表示標(biāo)記寬為20,高為10。
    symbol_size: types.Union[types.Numeric, types.Sequence, types.JSFunc] = 10,

    # 混合模式,目前支持'source-over','lighter'。
    # 默認(rèn)使用的'source-over'是通過 alpha 混合。
    # 而'lighter'是疊加模式,該模式可以讓數(shù)據(jù)集中的區(qū)域因?yàn)榀B加而產(chǎn)生高亮的效果。
    blend_mode: str = "source-over",

    # 僅在 Lines3D 起作用
    # 是否是多段線。
    # 默認(rèn)為 false,只能用于繪制只有兩個(gè)端點(diǎn)的線段(表現(xiàn)為被賽爾曲線)。
    # 如果該配置項(xiàng)為 true,則可以在 data.coords 中設(shè)置多于 2 個(gè)的頂點(diǎn)用來繪制多段線,在繪制路線軌跡的時(shí)候比較有用。
    is_polyline: bool = False,

    # 僅在 Lines3D 起作用
    # 飛線的尾跡特效,參考 `series_options.Line3DEffectOpts`
    effect: types.Lines3DEffect = None,

    # 僅在 Line3D,Lines3D 起作用
    # 飛線的線條樣式,參考 `series_options.LineStyleOpts`
    linestyle_opts: types.LineStyle = opts.LineStyleOpts(),

    # 僅在 Scatter3D,Bar3D,Map3D 起作用
    # 標(biāo)簽配置項(xiàng),參考 `series_options.LabelOpts`
    label_opts: types.Label = opts.LabelOpts(),

    # 提示框組件配置項(xiàng),參考 `series_options.TooltipOpts`
    tooltip_opts: types.Tooltip = None,

    # 僅在 Scatter3D,Bar3D,Map3D 起作用
    # 圖元樣式配置項(xiàng),參考 `series_options.ItemStyleOpts`
    itemstyle_opts: types.ItemStyle = None,

    # 僅在 Scatter3D,Bar3D,Map3D 起作用
    # 高亮標(biāo)簽配置項(xiàng),參考 `series_options.LabelOpts`
    emphasis_label_opts: types.Label = None,

    # 僅在 Scatter3D,Bar3D,Map3D 起作用
    # 高亮圖元樣式配置項(xiàng),參考 `series_options.ItemStyleOpts`
    emphasis_itemstyle_opts: types.ItemStyle = None,

    # 三維地圖中三維圖形的著色效果。echarts-gl 中支持下面三種著色方式:
    # color: 只顯示顏色,不受光照等其它因素的影響。
    # lambert: 通過經(jīng)典的 lambert 著色表現(xiàn)光照帶來的明暗。
    # realistic: 真實(shí)感渲染,配合 light.ambientCubemap 和 postEffect 使用可以讓展示的畫面效果和質(zhì)感有質(zhì)的提升。
    # ECharts GL 中使用了基于物理的渲染(PBR) 來表現(xiàn)真實(shí)感材質(zhì)。
    shading: types.Optional[str] = None,

    # 真實(shí)感材質(zhì)相關(guān)的配置項(xiàng),在 shading 為'realistic'時(shí)有效。
    realistic_material_opts: types.Optional[types.Map3DRealisticMaterial] = None,

    # lambert 材質(zhì)相關(guān)的配置項(xiàng),在 shading 為'lambert'時(shí)有效。
    lambert_material_opts: types.Optional[types.Map3DLambertMaterial] = None,

    # color 材質(zhì)相關(guān)的配置項(xiàng),在 shading 為'color'時(shí)有效。
    color_material_opts: types.Optional[types.Map3DColorMaterial] = None,

    # 組件所在的層。
    zlevel: types.Numeric = -10,

    # 圖形是否不響應(yīng)和觸發(fā)鼠標(biāo)事件,默認(rèn)為 false,即響應(yīng)和觸發(fā)鼠標(biāo)事件。
    is_silent: bool = False,

    # 是否開啟動(dòng)畫。
    is_animation: bool = True,

    # 過渡動(dòng)畫的時(shí)長。
    animation_duration_update: types.Numeric = 100,

    # 過渡動(dòng)畫的緩動(dòng)效果。
    animation_easing_update: types.Numeric = "cubicOut",
)

def add_schema(
    # 地圖類型,具體參考 pyecharts.datasets.map_filenames.json 文件
    maptype: str = "china",

    # 名稱
    name: types.Optional[str] = None,

    # 三維地理坐標(biāo)系組件在三維場景中的寬度。
    # 具體圖示在此: https://www.echartsjs.com/zh/documents/asset/gl/img/geo-size.png
    box_width: types.Optional[types.Numeric] = 100,

    # 三維地理坐標(biāo)系組件在三維場景中的高度。
    # 組件高度。這個(gè)高度包含三維地圖上的柱狀圖、散點(diǎn)圖的高度。
    box_height: types.Optional[types.Numeric] = 10,

    # 三維地理坐標(biāo)系組件在三維場景中的深度。
    # 組件深度默認(rèn)自動(dòng),保證三維組件的顯示比例跟輸入的 GeoJSON 的比例相同。
    box_depth: types.Optional[types.Numeric] = None,

    # 三維地圖每個(gè)區(qū)域的高度。這個(gè)高度是模型的高度,小于 boxHeight。
    # boxHeight - regionHeight 這一片區(qū)域會(huì)被用于三維柱狀圖,散點(diǎn)圖等的展示。
    region_height: types.Optional[types.Numeric] = 3,

    # 環(huán)境貼圖。支持純色、漸變色、全景貼圖的 url。
    # 默認(rèn)為 'auto',在配置有 light.ambientCubemap.texture 的時(shí)候會(huì)使用該紋理作為環(huán)境貼圖。
    # 否則則不顯示環(huán)境貼圖。
    # 示例:
    #  // 配置為全景貼圖
    #  environment: 'asset/starfield.jpg'
    #  // 配置為純黑色的背景
    #  environment: '#000'
    #  // 配置為垂直漸變的背景
    #  environment: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
    #    offset: 0, color: '#00aaff' // 天空顏色
    #  }, {
    #    offset: 0.7, color: '#998866' // 地面顏色
    #  }, {
    #    offset: 1, color: '#998866' // 地面顏色
    #  }], false)
    environment: types.Optional[types.JSFunc] = None,

    # 是否顯示地面。
    # 地面可以讓整個(gè)組件有個(gè)“擺放”的地方,從而使整個(gè)場景看起來更真實(shí),更有模型感。
    is_show_ground: bool = False,

    # 地面顏色。
    ground_color: str = "#aaa",

    # instancing會(huì)將 GeoJSON 中所有的 geometry 合并成一個(gè)
    # 在 GeoJSON 擁有特別多(上千)的 geometry 時(shí)可以有效提升繪制效率。
    is_instancing: bool = False,

    # Map3D 的 Label 設(shè)置
    map3d_label: types.Map3DLabel = None,

    # 圖元樣式配置項(xiàng),參考 `series_options.ItemStyleOpts`
    itemstyle_opts: types.ItemStyle = None,

    # 高亮標(biāo)簽配置項(xiàng),參考 `series_options.LabelOpts`
    emphasis_label_opts: types.Label = None,

    # 高亮圖元樣式配置項(xiàng),參考 `series_options.ItemStyleOpts`
    emphasis_itemstyle_opts: types.ItemStyle = None,

    # 三維地理坐標(biāo)系組件中三維圖形的著色效果。echarts-gl 中支持下面三種著色方式:
    # color: 只顯示顏色,不受光照等其它因素的影響。
    # lambert: 通過經(jīng)典的 lambert 著色表現(xiàn)光照帶來的明暗。
    # realistic: 真實(shí)感渲染,配合 light.ambientCubemap 和 postEffect 使用可以讓展示的畫面效果和質(zhì)感有質(zhì)的提升。
    # ECharts GL 中使用了基于物理的渲染(PBR) 來表現(xiàn)真實(shí)感材質(zhì)。
    shading: types.Optional[str] = None,

    # 真實(shí)感材質(zhì)相關(guān)的配置項(xiàng),在 shading 為'realistic'時(shí)有效。
    realistic_material_opts: types.Optional[types.Map3DRealisticMaterial] = None,

    # lambert 材質(zhì)相關(guān)的配置項(xiàng),在 shading 為'lambert'時(shí)有效。
    lambert_material_opts: types.Optional[types.Map3DLambertMaterial] = None,

    # color 材質(zhì)相關(guān)的配置項(xiàng),在 shading 為'color'時(shí)有效。
    color_material_opts: types.Optional[types.Map3DColorMaterial] = None,

    # 光照相關(guān)的設(shè)置。在 shading 為 'color' 的時(shí)候無效。
    # 光照的設(shè)置會(huì)影響到組件以及組件所在坐標(biāo)系上的所有圖表。
    # 合理的光照設(shè)置能夠讓整個(gè)場景的明暗變得更豐富,更有層次。
    light_opts: types.Optional[types.Map3DLight] = None,

    # 后處理特效的相關(guān)配置。后處理特效可以為畫面添加高光、景深、環(huán)境光遮蔽(SSAO)、調(diào)色等效果??梢宰屨麄€(gè)畫面更富有質(zhì)感。
    post_effect_opts: types.Optional[types.Map3DPostEffect] = None,

    # 是否開啟分幀超采樣。默認(rèn)在開啟 postEffect 后也會(huì)同步開啟。
    is_enable_super_sampling: types.Union[str, bool] = "auto",

    # viewControl用于鼠標(biāo)的旋轉(zhuǎn),縮放等視角控制。
    view_control_opts: types.Optional[types.Map3DViewControl] = None,

    # 組件所在的層。
    zlevel: types.Optional[types.Numeric] = -10,

    # 組件的視圖離容器左側(cè)的距離。
    # left 的值可以是像 20 這樣的具體像素值,可以是像 '20%' 這樣相對(duì)于容器高寬的百分比,
    # 也可以是 'left', 'center', 'right'。
    # 如果 left 的值為'left', 'center', 'right',組件會(huì)根據(jù)相應(yīng)的位置自動(dòng)對(duì)齊。
    pos_left: types.Union[types.Numeric, str] = "auto",

    # 組件的視圖離容器上側(cè)的距離。
    pos_top: types.Union[types.Numeric, str] = "auto",

    # 組件的視圖離容器右側(cè)的距離。
    pos_right: types.Union[types.Numeric, str] = "auto",

    # 組件的視圖離容器下側(cè)的距離。
    pos_bottom: types.Union[types.Numeric, str] = "auto",

    # 組件的視圖寬度。
    pos_width: types.Union[types.Numeric, str] = "auto",

    # 組件的視圖高度。
    pos_height: types.Union[types.Numeric, str] = "auto",
)

class Map3DLabelOpts(
    # 是否顯示標(biāo)簽。
    is_show: bool = True,

    # 標(biāo)簽距離圖形的距離,在三維的散點(diǎn)圖中這個(gè)距離是屏幕空間的像素值,其它圖中這個(gè)距離是相對(duì)的三維距離。
    distance: Numeric = None,

    # 標(biāo)簽內(nèi)容格式器,支持字符串模板和回調(diào)函數(shù)兩種形式,字符串模板與回調(diào)函數(shù)返回的字符串均支持用 \n 換行。
    # 模板變量有:
    # {a}:系列名。
    # :數(shù)據(jù)名。
    # {c}:數(shù)據(jù)值。
    formatter: Optional[JSFunc] = None,

    # 標(biāo)簽的字體樣式。
    text_style: Union[TextStyleOpts, dict, None] = None,
)

class Map3DRealisticMaterialOpts(
    # 材質(zhì)細(xì)節(jié)的紋理貼圖。
    detail_texture: Optional[JSFunc] = None,

    # 材質(zhì)細(xì)節(jié)紋理的平鋪。默認(rèn)為1,也就是拉伸填滿。大于 1 的時(shí)候,數(shù)字表示紋理平鋪重復(fù)的次數(shù)。
    # 注: 使用平鋪需要 detailTexture 的高寬是 2 的 n 次方。例如 512x512,如果是 200x200 的紋理無法使用平鋪。
    texture_tiling: Numeric = 1,

    # 材質(zhì)細(xì)節(jié)紋理的位移。
    texture_offset: Numeric = 0,

    # roughness 屬性用于表示材質(zhì)的粗糙度,0為完全光滑,1完全粗糙,中間的值則是介于這兩者之間。
    roughness: Numeric = 0.5,

    # metalness屬性用于表示材質(zhì)是金屬還是非金屬,0為非金屬,1為金屬,中間的值則是介于這兩者之間。
    # 通常設(shè)成0和1就能滿足大部分場景了。
    metalness: Numeric = 0,

    # 粗糙度調(diào)整,在使用粗糙度貼圖的時(shí)候有用??梢詫?duì)貼圖整體的粗糙度進(jìn)行調(diào)整。
    # 默認(rèn)為 0.5,0的時(shí)候?yàn)橥耆饣?的時(shí)候?yàn)橥耆植凇?
    roughness_adjust: Numeric = 0.5,

    # 金屬度調(diào)整,在使用金屬度貼圖的時(shí)候有用。可以對(duì)貼圖整體的金屬度進(jìn)行調(diào)整。
    # 默認(rèn)為 0.5,0的時(shí)候?yàn)榉墙饘伲?的時(shí)候?yàn)榻饘佟?
    metalness_adjust: Numeric = 0.5,

    # 材質(zhì)細(xì)節(jié)的法線貼圖。
    # 使用法線貼圖可以在較少的頂點(diǎn)下依然表現(xiàn)出物體表面豐富的明暗細(xì)節(jié)。
    normal_texture: Optional[JSFunc] = None,
)


class Map3DLambertMaterialOpts(
    # 材質(zhì)細(xì)節(jié)的紋理貼圖。
    detail_texture: Optional[JSFunc] = None,

    # 材質(zhì)細(xì)節(jié)紋理的平鋪。默認(rèn)為1,也就是拉伸填滿。大于 1 的時(shí)候,數(shù)字表示紋理平鋪重復(fù)的次數(shù)。
    # 注: 使用平鋪需要 detailTexture 的高寬是 2 的 n 次方。例如 512x512,如果是 200x200 的紋理無法使用平鋪。
    texture_tiling: Numeric = 1,

    # 材質(zhì)細(xì)節(jié)紋理的位移。
    texture_offset: Numeric = 0,
)

class Map3DColorMaterialOpts(
    # 材質(zhì)細(xì)節(jié)的紋理貼圖。
    detail_texture: Optional[JSFunc] = None,

    # 材質(zhì)細(xì)節(jié)紋理的平鋪。默認(rèn)為1,也就是拉伸填滿。大于 1 的時(shí)候,數(shù)字表示紋理平鋪重復(fù)的次數(shù)。
    # 注: 使用平鋪需要 detailTexture 的高寬是 2 的 n 次方。例如 512x512,如果是 200x200 的紋理無法使用平鋪。
    texture_tiling: Numeric = 1,

    # 材質(zhì)細(xì)節(jié)紋理的位移。
    texture_offset: Numeric = 0,
)

class Map3DLightOpts(
    # 主光源的顏色。
    main_color: str = "#fff",

    # 主光源的強(qiáng)度。
    main_intensity: Numeric = 1,

    # 主光源是否投射陰影。默認(rèn)為關(guān)閉。
    # 開啟陰影可以給場景帶來更真實(shí)和有層次的光照效果。但是同時(shí)也會(huì)增加程序的運(yùn)行開銷。
    is_main_shadow: bool = False,

    # 陰影的質(zhì)量。可選'low', 'medium', 'high', 'ultra'
    main_shadow_quality: str = "medium",

    # 主光源繞 x 軸,即上下旋轉(zhuǎn)的角度。配合 beta 控制光源的方向。
    # 圖示: https://www.echartsjs.com/zh/documents/asset/gl/img/light-alpha-beta.png
    main_alpha: Numeric = 40,

    # 主光源繞 y 軸,即左右旋轉(zhuǎn)的角度。
    main_beta: Numeric = 40,

    # 環(huán)境光的顏色。
    ambient_color: str = "#fff",

    # 環(huán)境光的強(qiáng)度。
    ambient_intensity: Numeric = 0.2,

    # 環(huán)境光貼圖的 url,支持使用.hdr格式的 HDR 圖片。
    # 可以從 http://www.hdrlabs.com/sibl/archive.html 等網(wǎng)站獲取 .hdr 的資源。
    ambient_cubemap_texture: Optional[str] = None,

    # 漫反射的強(qiáng)度。
    ambient_cubemap_diffuse_intensity: Numeric = 0.5,

    # 高光反射的強(qiáng)度。
    ambient_cubemap_specular_intensity: Numeric = 0.5,
)

class Map3DPostEffectOpts(
    # 是否開啟后處理特效。默認(rèn)關(guān)閉。
    is_enable: bool = False,

    # 是否開啟光暈特效。
    is_bloom_enable: bool = False,

    # 光暈的強(qiáng)度,默認(rèn)為 0.1
    bloom_intensity: Numeric = 0.1,

    # 是否開啟景深。
    is_depth_field_enable: bool = False,

    # 初始的焦距,用戶可以點(diǎn)擊區(qū)域自動(dòng)聚焦。
    depth_field_focal_distance: Numeric = 50,

    # 完全聚焦的區(qū)域范圍,在此范圍內(nèi)的物體時(shí)完全清晰的,不會(huì)有模糊
    depth_field_focal_range: Numeric = 20,

    # 鏡頭的F值,值越小景深越淺。
    depth_field_fstop: Numeric = 2.8,

    # 焦外的模糊半徑
    depth_field_blur_radius: Numeric = 10,

    # 是否開啟環(huán)境光遮蔽。默認(rèn)不開啟。
    is_ssao_enable: bool = False,

    # 環(huán)境光遮蔽的質(zhì)量。支持'low', 'medium', 'high', 'ultra'。
    ssao_quality: str = "medium",

    # 環(huán)境光遮蔽的采樣半徑。半徑越大效果越自然,但是需要設(shè)置較高的'quality'。
    ssao_radius: Numeric = 2,

    # 環(huán)境光遮蔽的強(qiáng)度。值越大顏色越深。
    ssao_intensity: Numeric = 1,

    # 是否開啟顏色糾正。
    is_color_correction_enable: bool = False,

    # 參考 Echarts 官方解釋。
    # 地址:https://www.echartsjs.com/zh/option-gl.html#geo3D.postEffect.colorCorrection.lookupTexture
    color_correction_lookup_texture: Optional[JSFunc] = None,

    # 畫面的曝光。
    color_correction_exposure: Numeric = 0,

    # 畫面的亮度。
    color_correction_brightness: Numeric = 0,

    # 畫面的對(duì)比度。
    color_correction_contrast: Numeric = 1,

    # 畫面的飽和度。
    color_correction_saturation: Numeric = 1,

    # 是否開啟 FXAA。默認(rèn)為不開啟。
    is_fxaa_enable: bool = False,
)

class Map3DViewControlOpts(
    # 投影方式,默認(rèn)為透視投影'perspective',也支持設(shè)置為正交投影'orthographic'。
    projection: str = "perspective",

    # 是否開啟視角繞物體的自動(dòng)旋轉(zhuǎn)查看。
    auto_rotate: bool = False,

    # 物體自轉(zhuǎn)的方向。默認(rèn)是 'cw' 也就是從上往下看是順時(shí)針方向,也可以取 'ccw',既從上往下看為逆時(shí)針方向。
    auto_rotate_direction: str = "cw",

    # 物體自轉(zhuǎn)的速度。單位為角度 / 秒,默認(rèn)為10 ,也就是36秒轉(zhuǎn)一圈。
    auto_rotate_speed: Numeric = 10,

    # 在鼠標(biāo)靜止操作后恢復(fù)自動(dòng)旋轉(zhuǎn)的時(shí)間間隔。在開啟 autoRotate 后有效。
    auto_rotate_after_still: Numeric = 3,

    # 鼠標(biāo)進(jìn)行旋轉(zhuǎn),縮放等操作時(shí)的遲滯因子,在大于 0 的時(shí)候鼠標(biāo)在停止操作后,視角仍會(huì)因?yàn)橐欢ǖ膽T性繼續(xù)運(yùn)動(dòng)(旋轉(zhuǎn)和縮放)。
    damping: Numeric = 0.8,

    # 旋轉(zhuǎn)操作的靈敏度,值越大越靈敏。支持使用數(shù)組分別設(shè)置橫向和縱向的旋轉(zhuǎn)靈敏度。
    # 默認(rèn)為1。
    # 設(shè)置為0后無法旋轉(zhuǎn)。
    # // 無法旋轉(zhuǎn)
    # rotateSensitivity: 0
    # // 只能橫向旋轉(zhuǎn)
    # rotateSensitivity: [1, 0]
    # // 只能縱向旋轉(zhuǎn)
    # rotateSensitivity: [0, 1]
    rotate_sensitivity: Union[Numeric, Sequence] = 1,

    # 縮放操作的靈敏度,值越大越靈敏。默認(rèn)為1。
    # 設(shè)置為0后無法縮放。
    zoom_sensitivity: Numeric = 1,

    # 平移操作的靈敏度,值越大越靈敏。支持使用數(shù)組分別設(shè)置橫向和縱向的平移靈敏度
    # 默認(rèn)為1。
    # 設(shè)置為0后無法平移。
    pan_sensitivity: Numeric = 1,

    # 平移操作使用的鼠標(biāo)按鍵,支持:
    #  'left' 鼠標(biāo)左鍵(默認(rèn))
    #  'middle' 鼠標(biāo)中鍵
    #  'right' 鼠標(biāo)右鍵
    #  注意:如果設(shè)置為鼠標(biāo)右鍵則會(huì)阻止默認(rèn)的右鍵菜單。
    pan_mouse_button: str = "left",

    # 旋轉(zhuǎn)操作使用的鼠標(biāo)按鍵,支持:
    #  'left' 鼠標(biāo)左鍵(默認(rèn))
    #  'middle' 鼠標(biāo)中鍵
    #  'right' 鼠標(biāo)右鍵
    #  注意:如果設(shè)置為鼠標(biāo)右鍵則會(huì)阻止默認(rèn)的右鍵菜單。
    rotate_mouse_button: str = "middle",

    # 默認(rèn)視角距離主體的距離,對(duì)于 globe 來說是距離地球表面的距離
    # 對(duì)于 grid3D 和 geo3D 等其它組件來說是距離中心原點(diǎn)的距離。
    # 在 projection 為'perspective'的時(shí)候有效。
    distance: Numeric = 100,

    # 視角通過鼠標(biāo)控制能拉近到主體的最小距離。在 projection 為'perspective'的時(shí)候有效。
    min_distance: Numeric = 40,

    # 視角通過鼠標(biāo)控制能拉遠(yuǎn)到主體的最大距離。在 projection 為'perspective'的時(shí)候有效。
    max_distance: Numeric = 400,

    # 正交投影的大小。在 projection 為'orthographic'的時(shí)候有效。
    orthographic_size: Numeric = 100,

    # 正交投影縮放的最大值。在 projection 為'orthographic'的時(shí)候有效。
    min_orthographic_size: Numeric = 20,

    # 正交投影縮放的最小值。在 projection 為'orthographic'的時(shí)候有效。
    max_orthographic_size: Numeric = 400,

    # 視角繞 x 軸,即上下旋轉(zhuǎn)的角度。配合 beta 可以控制視角的方向。
    alpha: Numeric = 40,

    # 視角繞 y 軸,即左右旋轉(zhuǎn)的角度。
    beta: Numeric = 0,

    # 視角中心點(diǎn),旋轉(zhuǎn)也會(huì)圍繞這個(gè)中心點(diǎn)旋轉(zhuǎn),默認(rèn)為[0,0,0]。
    center: Optional[Sequence] = None,

    # 上下旋轉(zhuǎn)的最小 alpha 值。即視角能旋轉(zhuǎn)到達(dá)最上面的角度。
    min_alpha: Numeric = 5,

    # 上下旋轉(zhuǎn)的最大 alpha 值。即視角能旋轉(zhuǎn)到達(dá)最下面的角度。
    max_alpha: Numeric = 90,

    # 左右旋轉(zhuǎn)的最小 beta 值。即視角能旋轉(zhuǎn)到達(dá)最左的角度。
    min_beta: Numeric = -80,

    # 左右旋轉(zhuǎn)的最大 beta 值。即視角能旋轉(zhuǎn)到達(dá)最右的角度。
    max_beta: Numeric = 80,

    # 是否開啟動(dòng)畫。
    animation: bool = True,

    # 過渡動(dòng)畫的時(shí)長。
    animation_duration_update: Numeric = 1000,

    # 過渡動(dòng)畫的緩動(dòng)效果。
    animation_easing_update: str = "cubicInOut",
)

Demo 舉例

1.具有移動(dòng)軌跡的3D地圖

example_data = [
    [[119.107078, 36.70925, 1000], [116.587245, 35.415393, 1000]],
    [[117.000923, 36.675807], [120.355173, 36.082982]],
    [[118.047648, 36.814939], [118.66471, 37.434564]],
    [[121.391382, 37.539297], [119.107078, 36.70925]],
    [[116.587245, 35.415393], [122.116394, 37.509691]],
    [[119.461208, 35.428588], [118.326443, 35.065282]],
    [[116.307428, 37.453968], [115.469381, 35.246531]],
]

from pyecharts import options as opts
from pyecharts.charts import Map3D
from pyecharts.globals import ChartType


c = (
    Map3D()
    .add_schema(
        maptype="山東",
        itemstyle_opts=opts.ItemStyleOpts(
            color="rgb(5,101,123)",
            opacity=1,
            border_width=0.8,
            border_color="rgb(62,215,213)",
        ),
        light_opts=opts.Map3DLightOpts(
            main_color="#fff",
            main_intensity=1.2,
            is_main_shadow=False,
            main_alpha=55,
            main_beta=10,
            ambient_intensity=0.3,
        ),
        view_control_opts=opts.Map3DViewControlOpts(center=[-10, 0, 10]),
        post_effect_opts=opts.Map3DPostEffectOpts(is_enable=False),
    )
    .add(
        series_name="",
        data_pair=example_data,
        type_=ChartType.LINES3D,
        effect=opts.Lines3DEffectOpts(
            is_show=True,
            period=4,
            trail_width=3,
            trail_length=0.5,
            trail_color="#f00",
            trail_opacity=1,
        ),
        linestyle_opts=opts.LineStyleOpts(is_show=False, color="#fff", opacity=0),
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="具有移動(dòng)軌跡的3D地圖"))
#     .render("具有移動(dòng)軌跡的3D地圖.html")
)
c.render_notebook()

在這里插入圖片描述

2.數(shù)據(jù)標(biāo)記點(diǎn)的3D地圖

example_data = [
    ("黑龍江", [127.9688, 45.368, 100]),
    ("內(nèi)蒙古", [110.3467, 41.4899, 100]),
    ("吉林", [125.8154, 44.2584, 100]),
    ("遼寧", [123.1238, 42.1216, 100]),
    ("河北", [114.4995, 38.1006, 100]),
    ("天津", [117.4219, 39.4189, 100]),
    ("山西", [112.3352, 37.9413, 100]),
    ("陜西", [109.1162, 34.2004, 100]),
    ("甘肅", [103.5901, 36.3043, 100]),
    ("寧夏", [106.3586, 38.1775, 100]),
    ("青海", [101.4038, 36.8207, 100]),
    ("新疆", [87.9236, 43.5883, 100]),
    ("西藏", [91.11, 29.97, 100]),
    ("四川", [103.9526, 30.7617, 100]),
    ("重慶", [108.384366, 30.439702, 100]),
    ("山東", [117.1582, 36.8701, 100]),
    ("河南", [113.4668, 34.6234, 100]),
    ("江蘇", [118.8062, 31.9208, 100]),
    ("安徽", [117.29, 32.0581, 100]),
    ("湖北", [114.3896, 30.6628, 100]),
    ("浙江", [119.5313, 29.8773, 100]),
    ("福建", [119.4543, 25.9222, 100]),
    ("江西", [116.0046, 28.6633, 100]),
    ("湖南", [113.0823, 28.2568, 100]),
    ("貴州", [106.6992, 26.7682, 100]),
    ("廣西", [108.479, 23.1152, 100]),
    ("海南", [110.3893, 19.8516, 100]),
    ("上海", [121.4648, 31.2891, 100]),
]

from pyecharts import options as opts
from pyecharts.charts import Map3D
from pyecharts.globals import ChartType
from pyecharts.commons.utils import JsCode



c = (
    Map3D()
    .add_schema(
        itemstyle_opts=opts.ItemStyleOpts(
            color="rgb(5,101,123)",
            opacity=1,
            border_width=0.8,
            border_color="rgb(62,215,213)",
        ),
        map3d_label=opts.Map3DLabelOpts(
            is_show=False,
            formatter=JsCode("function(data){return data.name + " " + data.value[2];}"),
        ),
        emphasis_label_opts=opts.LabelOpts(
            is_show=False,
            color="#fff",
            font_size=10,
            background_color="rgba(0,23,11,0)",
        ),
        light_opts=opts.Map3DLightOpts(
            main_color="#fff",
            main_intensity=1.2,
            main_shadow_quality="high",
            is_main_shadow=False,
            main_beta=10,
            ambient_intensity=0.3,
        ),
    )
    .add(
        series_name="Scatter3D",
        data_pair=example_data,
        type_=ChartType.SCATTER3D,
        bar_size=1,
        shading="lambert",
        label_opts=opts.LabelOpts(
            is_show=False,
            formatter=JsCode("function(data){return data.name + ' ' + data.value[2];}"),
        ),
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="數(shù)據(jù)標(biāo)記點(diǎn)的3D地圖"))
#     .render("數(shù)據(jù)標(biāo)記點(diǎn)的3D地圖.html")
)
c.render_notebook()

3.3D柱狀圖的3D地圖

example_data = [
    ("黑龍江", [127.9688, 45.368, 100]),
    ("內(nèi)蒙古", [110.3467, 41.4899, 300]),
    ("吉林", [125.8154, 44.2584, 300]),
    ("遼寧", [123.1238, 42.1216, 300]),
    ("河北", [114.4995, 38.1006, 300]),
    ("天津", [117.4219, 39.4189, 300]),
    ("山西", [112.3352, 37.9413, 300]),
    ("陜西", [109.1162, 34.2004, 300]),
    ("甘肅", [103.5901, 36.3043, 300]),
    ("寧夏", [106.3586, 38.1775, 300]),
    ("青海", [101.4038, 36.8207, 300]),
    ("新疆", [87.9236, 43.5883, 300]),
    ("西藏", [91.11, 29.97, 300]),
    ("四川", [103.9526, 30.7617, 300]),
    ("重慶", [108.384366, 30.439702, 300]),
    ("山東", [117.1582, 36.8701, 300]),
    ("河南", [113.4668, 34.6234, 300]),
    ("江蘇", [118.8062, 31.9208, 300]),
    ("安徽", [117.29, 32.0581, 300]),
    ("湖北", [114.3896, 30.6628, 300]),
    ("浙江", [119.5313, 29.8773, 300]),
    ("福建", [119.4543, 25.9222, 300]),
    ("江西", [116.0046, 28.6633, 300]),
    ("湖南", [113.0823, 28.2568, 300]),
    ("貴州", [106.6992, 26.7682, 300]),
    ("廣西", [108.479, 23.1152, 300]),
    ("海南", [110.3893, 19.8516, 300]),
    ("上海", [121.4648, 31.2891, 1300]),
]

from pyecharts import options as opts
from pyecharts.charts import Map3D
from pyecharts.globals import ChartType
from pyecharts.commons.utils import JsCode



c = (
    Map3D()
    .add_schema(
        itemstyle_opts=opts.ItemStyleOpts(
            color="rgb(5,101,123)",
            opacity=1,
            border_width=0.8,
            border_color="rgb(62,215,213)",
        ),
        map3d_label=opts.Map3DLabelOpts(
            is_show=False,
            formatter=JsCode("function(data){return data.name + " " + data.value[2];}"),
        ),
        emphasis_label_opts=opts.LabelOpts(
            is_show=False,
            color="#fff",
            font_size=10,
            background_color="rgba(0,23,11,0)",
        ),
        light_opts=opts.Map3DLightOpts(
            main_color="#fff",
            main_intensity=1.2,
            main_shadow_quality="high",
            is_main_shadow=False,
            main_beta=10,
            ambient_intensity=0.3,
        ),
    )
    .add(
        series_name="bar3D",
        data_pair=example_data,
        type_=ChartType.BAR3D,
        bar_size=1,
        shading="lambert",
        label_opts=opts.LabelOpts(
            is_show=False,
            formatter=JsCode("function(data){return data.name + ' ' + data.value[2];}"),
        ),
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="3D柱狀圖的3D地圖"))
#     .render("3D柱狀圖的3D地圖.html")
)
c.render_notebook()

4.全國行政區(qū)劃地圖

from pyecharts import options as opts
from pyecharts.charts import Map3D
from pyecharts.globals import ChartType

c = (
    Map3D()
    .add_schema(
        itemstyle_opts=opts.ItemStyleOpts(
            color="rgb(5,101,123)",
            opacity=1,
            border_width=0.8,
            border_color="rgb(62,215,213)",
        ),
        map3d_label=opts.Map3DLabelOpts(
            is_show=True,
            text_style=opts.TextStyleOpts(
                color="#fff", font_size=16, background_color="rgba(0,0,0,0)"
            ),
        ),
        emphasis_label_opts=opts.LabelOpts(is_show=True),
        light_opts=opts.Map3DLightOpts(
            main_color="#fff",
            main_intensity=1.2,
            is_main_shadow=False,
            main_alpha=55,
            main_beta=10,
            ambient_intensity=0.3,
        ),
    )
    .add(series_name="", data_pair="", maptype=ChartType.MAP3D)
    .set_global_opts(
        title_opts=opts.TitleOpts(title="China 3D Map-Base"),
        visualmap_opts=opts.VisualMapOpts(is_show=False),
        tooltip_opts=opts.TooltipOpts(is_show=True),
    )
#     .render("全國行政區(qū)劃地圖.html")
)
c.render_notebook()

5.世界人口分布地圖

import pyecharts.options as opts
from pyecharts.charts import MapGlobe
from pyecharts.faker import POPULATION

data = [x for _, x in POPULATION[1:]]
low, high = min(data), max(data)

c = (
    MapGlobe()
    .add_schema()
    .add(
        maptype="world",
        series_name="世界人口分布地圖",
        data_pair=POPULATION[1:],
        is_map_symbol_show=False,
        label_opts=opts.LabelOpts(is_show=False),
    )
    .set_global_opts(
        visualmap_opts=opts.VisualMapOpts(
            min_=low,
            max_=high,
            range_text=["max", "min"],
            is_calculable=True,
            range_color=["lightskyblue", "yellow", "orangered"],
        )
    )
#     .render("世界人口分布地圖.html")
)
c.render_notebook()

在這里插入圖片描述

到此這篇關(guān)于詳解如何使用Pyecharts制作Map3D的文章就介紹到這了,更多相關(guān)Pyecharts制作Map3D內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Pandas提取數(shù)據(jù)的三種方式

    Pandas提取數(shù)據(jù)的三種方式

    本文主要介紹了Pandas提取數(shù)據(jù)的三種方式,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • Xadmin+rules實(shí)現(xiàn)多選行權(quán)限方式(級(jí)聯(lián)效果)

    Xadmin+rules實(shí)現(xiàn)多選行權(quán)限方式(級(jí)聯(lián)效果)

    這篇文章主要介紹了Xadmin+rules實(shí)現(xiàn)多選行權(quán)限方式(級(jí)聯(lián)效果),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04
  • Django debug為True時(shí),css加載失敗的解決方案

    Django debug為True時(shí),css加載失敗的解決方案

    這篇文章主要介紹了Django debug為True時(shí),css加載失敗的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • python密碼學(xué)Base64編碼和解碼教程

    python密碼學(xué)Base64編碼和解碼教程

    這篇文章主要為大家介紹了python密碼學(xué)Base64編碼和解碼教程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05
  • Python 布爾類型示例精講

    Python 布爾類型示例精講

    這篇文章主要為大家介紹了Python 布爾類型示例精講,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • Python實(shí)現(xiàn)查詢剪貼板自動(dòng)匹配信息的思路詳解

    Python實(shí)現(xiàn)查詢剪貼板自動(dòng)匹配信息的思路詳解

    這篇文章主要介紹了Python實(shí)現(xiàn)查詢剪貼板自動(dòng)匹配信息,本文通過示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-07-07
  • 通過Python實(shí)現(xiàn)對(duì)SQL Server 數(shù)據(jù)文件大小的監(jiān)控告警功能

    通過Python實(shí)現(xiàn)對(duì)SQL Server 數(shù)據(jù)文件大小的監(jiān)控告警功能

    這篇文章主要介紹了通過Python實(shí)現(xiàn)對(duì)SQL Server 數(shù)據(jù)文件大小的監(jiān)控告警,本文給大家分享問題報(bào)錯(cuò)信息及解決方案,需要的朋友可以參考下
    2021-04-04
  • Python線程指南分享

    Python線程指南分享

    今天小編就為大家?guī)鞵ython線程指南分享,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • python+opencv實(shí)現(xiàn)攝像頭調(diào)用的方法

    python+opencv實(shí)現(xiàn)攝像頭調(diào)用的方法

    這篇文章主要為大家詳細(xì)介紹了python+opencv實(shí)現(xiàn)攝像頭調(diào)用的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-06-06
  • Python爬蟲之App爬蟲視頻下載的實(shí)現(xiàn)

    Python爬蟲之App爬蟲視頻下載的實(shí)現(xiàn)

    這篇文章主要介紹了Python爬蟲之App爬蟲視頻下載的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12

最新評(píng)論