Python应用开发——30天学习Streamlit Python包进行APP的构建(11)

st.bokeh_chart

显示互动式虚化图。

Bokeh 是 Python 的一个图表库。此函数的参数与 Bokeh 的 show 函数的参数非常接近。有关 Bokeh 的更多信息,请访问 https://bokeh.pydata.org。

要在 Streamlit 中显示 Bokeh 图表,请在调用 Bokeh 的 show 时调用 st.bokeh_chart。

Function signature[source]

st.bokeh_chart(figure, use_container_width=False)

Parameters

figure (bokeh.plotting.figure.Figure)

A Bokeh figure to plot.

use_container_width (bool)

Whether to override the figure's native width with the width of the parent container. If use_container_width is False (default), Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. If use_container_width is True, Streamlit sets the width of the figure to match the width of the parent container.

代码

import streamlit as st
from bokeh.plotting import figurex = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]p = figure(title='simple line example',x_axis_label='x',y_axis_label='y')p.line(x, y, legend_label='Trend', line_width=2)st.bokeh_chart(p, use_container_width=True)

这段代码使用了Streamlit和Bokeh库来创建一个简单的折线图。首先,我们导入了streamlit和bokeh.plotting中的figure模块。然后,我们定义了x和y轴的数据点。接下来,我们创建了一个Bokeh图形对象p,并设置了标题、x轴标签和y轴标签。然后,我们使用p.line()方法在图形对象上绘制了折线,设置了图例标签和线宽。最后,我们使用st.bokeh_chart()方法将图形对象p显示在Streamlit应用程序中,并设置了use_container_width=True以适应容器的宽度。Bokeh

st.graphviz_chart 

使用 dagre-d3 库显示图表。

Function signature[source]

st.graphviz_chart(figure_or_dot, use_container_width=False)

Parameters

figure_or_dot (graphviz.dot.Graph, graphviz.dot.Digraph, str)

The Graphlib graph object or dot string to display

use_container_width (bool)

Whether to override the figure's native width with the width of the parent container. If use_container_width is False (default), Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. If use_container_width is True, Streamlit sets the width of the figure to match the width of the parent container.

代码

import streamlit as st
import graphviz# Create a graphlib graph object
graph = graphviz.Digraph()
graph.edge('run', 'intr')
graph.edge('intr', 'runbl')
graph.edge('runbl', 'run')
graph.edge('run', 'kernel')
graph.edge('kernel', 'zombie')
graph.edge('kernel', 'sleep')
graph.edge('kernel', 'runmem')
graph.edge('sleep', 'swap')
graph.edge('swap', 'runswap')
graph.edge('runswap', 'new')
graph.edge('runswap', 'runmem')
graph.edge('new', 'runmem')
graph.edge('sleep', 'runmem')st.graphviz_chart(graph)

这段代码使用了Streamlit和Graphviz库。首先,导入了streamlit和graphviz模块。然后创建了一个graphviz的有向图对象graph。接着,通过调用edge方法,向图中添加了一系列的边,构成了一个简单的图形结构。最后,使用st.graphviz_chart方法将图形显示在Streamlit应用程序中。整体来说,这段代码的作用是创建一个简单的有向图并在Streamlit应用程序中展示出来。或者,您也可以使用 GraphViz 的 Dot 语言从图形中渲染图表:

st.graphviz_chart('''digraph {run -> intrintr -> runblrunbl -> runrun -> kernelkernel -> zombiekernel -> sleepkernel -> runmemsleep -> swapswap -> runswaprunswap -> newrunswap -> runmemnew -> runmemsleep -> runmem}
''')

 st.plotly_chart

显示交互式 Plotly 图表。

Plotly 是 Python 的图表库。该函数的参数与 Plotly 的 plot() 函数的参数非常接近。

要在 Streamlit 中显示 Plotly 图表,请在调用 Plotly 的 py.plot 或 py.iplot 时调用 st.plotly_chart。

Function signature[source]

st.plotly_chart(figure_or_data, use_container_width=False, *, theme="streamlit", key=None, on_select="ignore", selection_mode=('points', 'box', 'lasso'), **kwargs)

Returns

(element or dict)

If on_select is "ignore" (default), this method returns an internal placeholder for the chart element. Otherwise, this method returns a dictionary-like object that supports both key and attribute notation. The attributes are described by the PlotlyState dictionary schema.

Parameters

figure_or_data (plotly.graph_objs.Figure, plotly.graph_objs.Data, or dict/list of plotly.graph_objs.Figure/Data)

The Plotly Figure or Data object to render. See Plotly Python Graphing Library for examples of graph descriptions.

use_container_width (bool)

Whether to override the figure's native width with the width of the parent container. If use_container_width is False (default), Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. If use_container_width is True, Streamlit sets the width of the figure to match the width of the parent container.

theme ("streamlit" or None)

The theme of the chart. If theme is "streamlit" (default), Streamlit uses its own design default. If theme is None, Streamlit falls back to the default behavior of the library.

key (str)

An optional string to use for giving this element a stable identity. If key is None (default), this element's ide

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/862518.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

jsonata工具查询JSON和转换

jsonata工具查询JSON和转换 参考网址:http://docs.jsonata.org/1.7.0/date-time https://github.com/IBM/JSONata4Java 简介 JSONata是IBM的OPen Source项目,正是这样做的。它是一种用于查询和转换 JSON 数据结构的表达式语言。JSONata 是一种用于查询…

Android 系统设置中的休眠和屏保

简介 由于客户在Android 系统设置中发现Timeout设置项没有效果,因此我对此研究了一下。Timeout是定时屏幕亮度降低,而Dream则是进入屏幕保护。如果是机顶盒等设备的开发者发现这个设置项没用,别见外,因为这里的亮度调整对TV是没用…

二叉树的方法

目录 一、二叉树的定义 ​编辑 二、二叉树的创建 三、二叉树的遍历 1、前序遍历 2、中序遍历 3、后序遍历 4、层序遍历 四、二叉树遍历方法的使用 五、二叉树的操作 1、节点的个数 2、叶子节点的个数 3、第k层节点的个数 4、二叉树的高度 5、检查值为value的元素…

java生成excel,uniapp微信小程序接收excel并打开

java引包&#xff0c;引的是apache.poi <dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>5.2.3</version></dependency> 写一个测试类&#xff0c;把excel输出到指定路径 public s…

一条SQL查询语句的执行流程

MySQL 中一条 SQL 查询语句的执行流程可以分为以下几个主要步骤&#xff1a; 客户端请求&#xff1a; 客户端通过 MySQL 客户端或应用程序向 MySQL 服务器发送 SQL 查询请求。 连接管理&#xff1a; MySQL 服务器接收到请求后&#xff0c;会首先检查客户端的身份验证信息&…

c++笔记容器详细介绍

C标准库提供了多种容器来存储和管理数据。这些容器属于<vector>, <list>, <deque>, <map>, <set>, <unordered_map>, <unordered_set>等头文件中。这些容器各有优缺点&#xff0c;适用于不同的场景。下面详细介绍几种主要的容器及其…

快20倍还便宜 NVIDIA GPU的“掘墓人”出现了?

芯片初创公司Etched近日宣布推出了一款针对 Transformer架构专用的AISC芯片 “Sohu”&#xff0c;并声称其在AI大语言模型&#xff08;LLM&#xff09;推理性能方面击败了NVIDIA最新的B200 GPU&#xff0c;AI性能达到了H100的20倍。这也意味着Sohu芯片将可以大幅降低现有AI数据…

【面试系列】C++ 高频面试题

欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;欢迎订阅相关专栏&#xff1a; ⭐️ 全网最全IT互联网公司面试宝典&#xff1a;收集整理全网各大IT互联网公司技术、项目、HR面试真题. ⭐️ AIGC时代的创新与未来&#xff1a;详细讲解AIGC的概念、核心技术、…

精密机器中的交叉导轨负荷与容许负荷的差异!

交叉导轨的设计和制造过程中&#xff0c;负荷及容许负荷是至关重要的参数&#xff0c;只有准确计算出交叉导轨的载荷&#xff0c;才能保证交叉导轨的稳定性和使用寿命。 负荷和容许载荷是两个不同的参数&#xff0c;那这两者的有什么差异呢&#xff1f; 交叉导轨的负荷是指其承…

微信群被恶意举报封了加新群的看这里

由于近期太忙&#xff0c;有时候手机被儿子拿玩看动漫了&#xff0c;被误删或是误踢的朋友说声抱歉。 感谢大家的理解和支持。

JVM专题九:JVM分代知识点梳理

今天开始&#xff0c;咱们开始剖析JVM内存划分的原理细节&#xff0c;以及我们创建的那些对象在JVM中到底是如何分配&#xff0c;如何流动的&#xff0c;首先解决第一个问题&#xff1a;JVM内存的一个分代模型:年轻代、老年代、永久通过之前的专题我们知道&#xff0c;那就是我…

HarmonyOS Next开发学习手册——通过startAbilityByType拉起垂类应用

使用场景 开发者可通过特定的业务类型如导航、金融等&#xff0c;调用startAbilityByType接口拉起对应的垂域面板&#xff0c;该面板将展示目标方接入的垂域应用&#xff0c;由用户选择打开指定应用以实现相应的垂类意图。垂域面板为调用方提供统一的安全、可信的目标方应用&a…

REST API 中的 HTTP 请求参数

当我们在谈论现代 Web 开发时&#xff0c;REST API (Representational State Transfer Application Programming Interface) 扮演着至关重要的角色。它允许不同的系统以一种简洁且高效的方式进行通信。HTTP 请求参数是控制此通信流程中数据如何被发送和接收的重要组成部分。 H…

vue2使用wangEditor5搭建模拟文档的编辑器快速集成

如图 1、下载依赖 2、elm引入&#xff08;可省略&#xff09; main.js 或者 按需引入 3、cv <template><div style"background: #f1f3f4"><div style"width: 100%; height: 42px"><!-- 工具栏 --><Toolbarid"tool-conta…

Linux crontab中* * * * * /usr/local/run.sh这句话5个*号分别代表什么?

在 Linux crontab 中&#xff0c;* * * * * /usr/local/run.sh 这句话里的 5 个*号分别代表的含义如下&#xff1a; 第一个&#xff1a;表示分钟&#xff0c;取值范围是 0 到 59。这里的表示每分钟。 第二个&#xff1a;表示小时&#xff0c;取值范围是 0 到 23。表示每小时。…

AI产品经理需要懂的算法和模型

本篇希望以精准推荐模型为案例通过全面的撰写将AI产品经理需要懂的算法和模型进行了系统的入门讲解。 一个产品经理经常疑惑的概念&#xff1a; 算法和模型的关系&#xff0c;产品经理懂得解决问题时将问题抽象为模型&#xff0c;对模型求解用算法&#xff0c;没有谁大谁小&a…

博睿数据受邀出席GOPS全球运维大会北京站,分享《一体化可观测数据模型和AIOps的融合实践》

2024年6月28日&#xff0c;第二十三届 GOPS 全球运维大会暨 XOps 技术创新峰会在北京顺利召开。大会为期2天&#xff0c;侧重 BizDevOps、XOps、DevOps、持续测试、SRE、可观测性、云原生等热门技术领域。并特别设置大模型运维、银行/证券数字化转型、平台工程、DevOps/AIOps 最…

Linux系统中常用的基本命令

1. 文件与目录管理 ls: 列出目录内容。cd: 切换当前工作目录。pwd: 显示当前工作目录的路径。mkdir: 创建一个新目录。rmdir: 删除空目录。cp: 复制文件或目录。mv: 移动或重命名文件或目录。rm: 删除文件或目录。touch: 创建一个空文件或更新文件时间戳。 2. 文本内容查看 …

bcprov-jdk15on和bcpkix-jdk15on有什么区别

bcprov-jdk15on 和 bcpkix-jdk15on 都是 Bouncy Castle 密码库的不同组件&#xff0c;针对不同的用途和功能。它们之间的主要区别在于提供的功能和目的&#xff1a; bcprov-jdk15on&#xff1a; 这是 Bouncy Castle 的主要提供者&#xff08;Provider&#xff09;模块&#xff…

上海六十中学多功能气膜馆项目:轻空间全速推进

项目进展捷报频传 上海六十中学多功能气膜馆项目土建工作已基本完工&#xff0c;今天轻空间团队正式进场&#xff0c;展开气膜部分的施工。我们将为上海六十中学打造一个现代化、环保、高效的多功能气膜馆&#xff0c;提供优质的运动和活动场所。 现场施工一片繁忙 在施工现场&…