【Python学习】—Python数据可视化(八)

【Python学习】---Python基础语法(八)

一、JSON数据格式

  • JSON是一种轻量级的数据交互格式,可以按照JSON指定的格式去组织和封装数据
  • JSON本质上是 一个带有特定格式的字符串
  • JSON就是一种在各个编程语言中流通的数据格式,负责不同编程语言中的数据传递和交互

Python数据和JSON数据的相互转化




二、pyecharts模块

  • 如果想要做出可视画效果图,可以借助pyecharts模块来完成
  • Echarts 是一个由百度开源的数据可视化,凭借着良好的交互性,精巧的图表设计,得到了众多开发者的认可。而 Python 是一门富有表达力的语言,很适合用于数据处理。当数据分析遇上数据可视化时,pyecharts 诞生了。


pycharts中有哪些配置选项

  • 全局配置选项
  • 系列配置选项


bash 复制代码
from pyecharts.charts import Line
from pyecharts.options import TitleOpts,LegendOpts,ToolboxOpts,VisualMapOpts

line=Line()
line.add_xaxis(["中国","英国","美国"])
line.add_yaxis("GDP",[30,20,10])

line.set_global_opts(
    title_opts=TitleOpts(title="GDP展示",pos_left="center", pos_bottom="1%"),
    legend_opts=LegendOpts(is_show=True),
    toolbox_opts=ToolboxOpts(is_show=True),
    visualmap_opts=VisualMapOpts(is_show=True)
)
line.render()

总结

三、地图可视化

bash 复制代码
from pyecharts.charts import Map
from pyecharts.options import VisualMapOpts

map=Map()
data=[
    ("北京市",99),
    ("上海市", 199),
    ("湖南省", 299),
    ("台湾省", 399),
    ("广东省", 499),
]
map.add("测试地图",data,"china")

#设置全局选项
map.set_global_opts(
    visualmap_opts=VisualMapOpts(
        is_show=True,
        is_piecewise=True,
        pieces=[
            {"min":1,"max":9,"label":"1-9","color":'#CCFFFF'},
{"min":10,"max":99,"label":"10-99","color":'pink'},
{"min":100,"max":500,"label":"100-500","color":'red'}]
    )
)
map.render()

四、动态柱状图

bash 复制代码
from pyecharts.charts import Bar
from pyecharts.options import LabelOpts
bar=Bar()
bar.add_xaxis(["中国","美国","英国"])
bar.add_yaxis("GDP",[30,20,10],label_opts=LabelOpts(
    position="right"
))
#反转xy轴
bar.reversal_axis()
bar.render("基础柱状图.html")

五、时间线柱状图

bash 复制代码
from pyecharts.charts import Bar,Timeline
from pyecharts.options import LabelOpts
from pyecharts.globals import ThemeType

bar1=Bar()
bar1.add_xaxis(["中国","美国","英国"])
bar1.add_yaxis("GDP",[30,20,10],label_opts=LabelOpts(
    position="right"
))
bar1.reversal_axis()

bar2=Bar()
bar2.add_xaxis(["中国","美国","英国"])
bar2.add_yaxis("GDP",[40,30,20],label_opts=LabelOpts(
    position="right"
))
bar2.reversal_axis()

bar3=Bar()
bar3.add_xaxis(["中国","美国","英国"])
bar3.add_yaxis("GDP",[50,60,40],label_opts=LabelOpts(
    position="right"
))
bar3.reversal_axis()

#构建时间线
timeline=Timeline()
{
        "theme":ThemeType.LIGHT
    }
timeline.add(bar1,"点1")
timeline.add(bar2,"点2")
timeline.add(bar3,"点3")
#设置自动播放
timeline.add_schema(
    play_interval=1000,
    is_timeline_show=True,
    is_auto_play=True,
    is_loop_play=True
)
timeline.render("基础时间线柱状图.html")

六、列表的sort方法


相关推荐
万邦科技Lafite3 小时前
京东按图搜索京东商品(拍立淘) API (.jd.item_search_img)快速抓取数据
开发语言·前端·数据库·python·电商开放平台·京东开放平台
丁浩6664 小时前
Python机器学习---6.集成学习与随机森林
python·随机森林·机器学习
wdfk_prog5 小时前
[Linux]学习笔记系列 -- [kernel][time]alarmtimer
linux·笔记·学习
charlie1145141915 小时前
现代 Python 学习笔记:Statements & Syntax
笔记·python·学习·教程·基础·现代python·python3.13
ha20428941945 小时前
Linux操作系统学习之---基于环形队列的生产者消费者模型(毛坯版)
linux·c++·学习
dxnb225 小时前
Datawhale25年10月组队学习:math for AI+Task5解析几何
人工智能·学习
哲Zheᗜe༘5 小时前
了解学习Redis主从复制
数据库·redis·学习
井队Tell7 小时前
打造高清3D虚拟世界|零基础学习Unity HDRP高清渲染管线(第九天)
学习·3d·unity
麦麦大数据8 小时前
F036 vue+flask中医热性药知识图谱可视化系统vue+flask+echarts+mysql
vue.js·python·mysql·flask·可视化·中医中药
移远通信8 小时前
MQTT协议:物联网时代的通信革命
python·物联网·网络协议