当前位置: 首页 > news >正文

购买网站做网页游戏适合中层管理的培训

购买网站做网页游戏,适合中层管理的培训,创作网站,WordPress禁用评论回收站文章目录 1、简介2、安装3、测试3.1 创建折线图3.2 添加和自定义渲染器3.3 添加图例、文本和批注3.4 自定义您的绘图3.5 矢量化字形属性3.6 合并绘图3.7 显示和导出3.8 提供和筛选数据3.9 使用小部件3.10 嵌入Bokeh图表到Flask应用程序 结语 1、简介 https://bokeh.org/ https…

文章目录

  • 1、简介
  • 2、安装
  • 3、测试
    • 3.1 创建折线图
    • 3.2 添加和自定义渲染器
    • 3.3 添加图例、文本和批注
    • 3.4 自定义您的绘图
    • 3.5 矢量化字形属性
    • 3.6 合并绘图
    • 3.7 显示和导出
    • 3.8 提供和筛选数据
    • 3.9 使用小部件
    • 3.10 嵌入Bokeh图表到Flask应用程序
  • 结语

1、简介

https://bokeh.org/
https://github.com/bokeh/bokeh

Bokeh是一个Python库,用于创建交互式的、现代化的Web可视化工具。它允许用户创建各种类型的图表,包括线图、散点图、柱状图、热图等,而且这些图表都可以在Web浏览器中交互式地操作。
在这里插入图片描述
Bokeh 是用于现代 Web 浏览器的交互式可视化库。它提供了优雅、简洁的多功能图形结构,并在大型或流数据集之间提供高性能交互性。Bokeh 可以帮助任何想要快速轻松地创建交互式绘图、仪表板和数据应用程序的人。

在这里插入图片描述

  • 交互性:Bokeh提供了丰富的交互性选项,使用户能够在图表上进行缩放、平移、选择数据点等操作。

  • 现代化的外观:Bokeh的图表外观非常现代化和吸引人,可以定制颜色、线条样式等。

  • 多种输出格式:Bokeh支持多种输出格式,包括HTML、Jupyter Notebook、交互式应用程序等。

  • 无需前端开发经验:使用Bokeh,不需要具备前端开发的经验,就可以创建交互式的Web可视化。

  • 支持大数据集:Bokeh能够有效地处理大数据集,因此适用于各种规模的数据分析任务。

Bokeh是一个用于数据可视化的强大工具,它能够创建交互式、高性能且具有各种可视化样式的图表。Bokeh提供了Python、R、Scala和Julia等多个编程语言的接口,使得用户可以根据自己的喜好选择使用。

在将Bokeh绘图嵌入到网站中之前,我们需要将绘图文件上传到网站的服务器。一种常见的方法是将绘图作为静态资源存储在服务器上,并在网站的HTML代码中引用它。

2、安装

请在 Bash 或 Windows 命令提示符下输入以下pip命令:

pip install bokeh

在这里插入图片描述

3、测试

3.1 创建折线图

Bokeh允许您使用Python构建在web浏览器中运行的交互式可视化。为了实现这一点,Bokeh包含了一个名为BokehJS的JavaScript库。BokehJS负责在浏览器中呈现可视化效果。
当您在Python中使用Bokeh创建可视化时,Bokeh会将此可视化转换为JSON文件。然后,这个JSON文件被发送到BokehJS,BokehJS在浏览器中呈现可视化效果。

在这里插入图片描述
在Python中使用Bokeh,它会自动生成BokehJS代码。但是,您也可以在JavaScript中直接使用BokehJS。
在这里插入图片描述

from bokeh.plotting import figure, show# generate some values
x = list(range(1, 50))
y = [pow(x, 2) for x in x]# create a new plot
p = figure()
# add a line renderer and legend to the plot
p.line(x, y, legend_label="Temp.")# show the results
show(p)

在这里插入图片描述

from bokeh.plotting import figure, show# prepare some data
x = [1, 2, 3, 4, 5]
y1 = [6, 7, 2, 4, 5]
y2 = [2, 3, 4, 5, 6]
y3 = [4, 5, 5, 7, 2]# create a new plot with a title and axis labels
p = figure(title="Multiple line example", x_axis_label="x", y_axis_label="y")# add multiple renderers
p.line(x, y1, legend_label="Temp.", color="blue", line_width=2)
p.line(x, y2, legend_label="Rate", color="red", line_width=2)
p.line(x, y3, legend_label="Objects", color="green", line_width=2)# show the results
show(p)

在这里插入图片描述

3.2 添加和自定义渲染器

在本节中,您将使用不同的渲染器函数来创建各种 其他类型的图形。您还将自定义字形的外观。

from bokeh.plotting import figure, show# prepare some data
x = [1, 2, 3, 4, 5]
y1 = [6, 7, 2, 4, 5]
y2 = [2, 3, 4, 5, 6]
y3 = [4, 5, 5, 7, 2]# create a new plot with a title and axis labels
p = figure(title="Multiple glyphs example", x_axis_label="x", y_axis_label="y")# add multiple renderers
p.line(x, y1, legend_label="Temp.", color="#004488", line_width=3)
p.line(x, y2, legend_label="Rate", color="#906c18", line_width=3)
p.scatter(x, y3, legend_label="Objects", color="#bb5566", size=16)# show the results
show(p)

在这里插入图片描述

3.3 添加图例、文本和批注

from bokeh.plotting import figure, show# prepare some data
x = [1, 2, 3, 4, 5]
y1 = [4, 5, 5, 7, 2]
y2 = [2, 3, 4, 5, 6]# create a new plot
p = figure(title="Legend example")# add circle renderer with legend_label arguments
line = p.line(x, y1, legend_label="Temp.", line_color="blue", line_width=2)
circle = p.scatter(x,y2,marker="circle",size=80,legend_label="Objects",fill_color="red",fill_alpha=0.5,line_color="blue",
)# display legend in top left corner (default is top right corner)
p.legend.location = "top_left"# add a title to your legend
p.legend.title = "Obervations"# change appearance of legend text
p.legend.label_text_font = "times"
p.legend.label_text_font_style = "italic"
p.legend.label_text_color = "navy"# change border and background of legend
p.legend.border_line_width = 3
p.legend.border_line_color = "navy"
p.legend.border_line_alpha = 0.8
p.legend.background_fill_color = "navy"
p.legend.background_fill_alpha = 0.2# show the results
show(p)

在这里插入图片描述

3.4 自定义您的绘图

from bokeh.io import curdoc
from bokeh.plotting import figure, show# prepare some data
x = [1, 2, 3, 4, 5]
y = [4, 5, 5, 7, 2]# apply theme to current document
curdoc().theme = "dark_minimal"# create a plot
p = figure(sizing_mode="stretch_width", max_width=500, height=250)# add a renderer
p.line(x, y)# show the results
show(p)

在这里插入图片描述

3.5 矢量化字形属性

生成了 不同的字形并定义了它们的外观。

import randomfrom bokeh.plotting import figure, show# generate some data (1-10 for x, random values for y)
x = list(range(0, 26))
y = random.sample(range(0, 100), 26)# generate list of rgb hex colors in relation to y
colors = [f"#{255:02x}{int((value * 255) / 100):02x}{255:02x}" for value in y]# create new plot
p = figure(title="Vectorized colors example",sizing_mode="stretch_width",max_width=500,height=250,
)# add line and scatter renderers
p.line(x, y, line_color="blue", line_width=1)
p.scatter(x, y, fill_color=colors, line_color="blue", size=15)# show the results
show(p)

在这里插入图片描述

3.6 合并绘图

把多个地块组合成不同类型的布局。

from bokeh.layouts import row
from bokeh.plotting import figure, show# prepare some data
x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]# create three plots with one renderer each
s1 = figure(width=250, height=250, background_fill_color="#fafafa")
s1.scatter(x, y0, marker="circle", size=12, color="#53777a", alpha=0.8)s2 = figure(width=250, height=250, background_fill_color="#fafafa")
s2.scatter(x, y1, marker="triangle", size=12, color="#c02942", alpha=0.8)s3 = figure(width=250, height=250, background_fill_color="#fafafa")
s3.scatter(x, y2, marker="square", size=12, color="#d95b43", alpha=0.8)# put the results in a row and show
show(row(s1, s2, s3))

在这里插入图片描述

3.7 显示和导出

创建了 自定义和组合的可视化效果。

from bokeh.plotting import figure, output_file, save# prepare some data
x = [1, 2, 3, 4, 5]
y = [4, 5, 5, 7, 2]# set output to static HTML file
output_file(filename="custom_filename.html", title="Static HTML file")# create a new plot with a specific size
p = figure(sizing_mode="stretch_width", max_width=500, height=250)# add a scatter renderer
p.scatter(x, y, fill_color="red", size=15)# save the results to a file
save(p)

在这里插入图片描述

3.8 提供和筛选数据

使用了不同的 用于显示和导出可视化效果的方法。

from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource# create dict as basis for ColumnDataSource
data = {'x_values': [1, 2, 3, 4, 5],'y_values': [6, 7, 2, 3, 6]}# create ColumnDataSource based on dict
source = ColumnDataSource(data=data)# create a plot and renderer with ColumnDataSource data
p = figure(height=250)
p.scatter(x='x_values', y='y_values', size=20, source=source)
show(p)

在这里插入图片描述

from bokeh.layouts import gridplot
from bokeh.models import CDSView, ColumnDataSource, IndexFilter
from bokeh.plotting import figure, show# create ColumnDataSource from a dict
source = ColumnDataSource(data=dict(x=[1, 2, 3, 4, 5], y=[1, 2, 3, 4, 5]))# create a view using an IndexFilter with the index positions [0, 2, 4]
view = CDSView(filter=IndexFilter([0, 2, 4]))# setup tools
tools = ["box_select", "hover", "reset"]# create a first plot with all data in the ColumnDataSource
p = figure(height=300, width=300, tools=tools)
p.scatter(x="x", y="y", size=10, hover_color="red", source=source)# create a second plot with a subset of ColumnDataSource, based on view
p_filtered = figure(height=300, width=300, tools=tools)
p_filtered.scatter(x="x", y="y", size=10, hover_color="red", source=source, view=view)# show both plots next to each other in a gridplot layout
show(gridplot([[p, p_filtered]]))

在这里插入图片描述

3.9 使用小部件

from bokeh.layouts import layout
from bokeh.models import Div, RangeSlider, Spinner
from bokeh.plotting import figure, show# prepare some data
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y = [4, 5, 5, 7, 2, 6, 4, 9, 1, 3]# create plot with circle glyphs
p = figure(x_range=(1, 9), width=500, height=250)
points = p.scatter(x=x, y=y, size=30, fill_color="#21a7df")# set up textarea (div)
div = Div(text="""<p>Select the circle's size using this control element:</p>""",width=200,height=30,
)# set up spinner
spinner = Spinner(title="Circle size",low=0,high=60,step=5,value=points.glyph.size,width=200,
)
spinner.js_link("value", points.glyph, "size")# set up RangeSlider
range_slider = RangeSlider(title="Adjust x-axis range",start=0,end=10,step=1,value=(p.x_range.start, p.x_range.end),
)
range_slider.js_link("value", p.x_range, "start", attr_selector=0)
range_slider.js_link("value", p.x_range, "end", attr_selector=1)# create layout
layout = layout([[div, spinner],[range_slider],[p],],
)# show result
show(layout)

在这里插入图片描述

3.10 嵌入Bokeh图表到Flask应用程序

要在Flask应用中嵌入一个Bokeh应用,我们需要进行以下步骤:

  • 安装Bokeh和Flask库。
  • 创建一个Flask应用。
  • 在Flask应用中创建一个Bokeh绘图函数。
  • 创建一个包含Bokeh绘图函数的HTML模板。
  • 在Flask应用中创建一个路由,渲染HTML模板并运行Bokeh绘图函数。

app.py代码如下:

from flask import Flask, render_template
from bokeh.plotting import figure
from bokeh.embed import componentsapp = Flask(__name__)@app.route('/')
def index():# 创建一个图表对象p = figure(title="Embedded Bokeh Plot")# 添加数据点x = [1, 2, 3, 4, 5]y = [6, 7, 2, 4, 5]# 绘制折线p.line(x, y, line_width=2)# 将图表组件嵌入到HTML模板中script, div = components(p)return render_template('index.html', script=script, div=div)if __name__ == '__main__':app.run()

index.html代码如下:

<!DOCTYPE html>
<html>
<head><title>Bokeh Plot</title><link href="https://cdn.bokeh.org/bokeh/release/bokeh-3.4.2.min.css" rel="stylesheet" type="text/css"><script src="https://cdn.bokeh.org/bokeh/release/bokeh-3.4.2.min.js"></script>
</head>
<body><h1>Bokeh Plot</h1><div>{{ script | safe }}{{ div | safe }}</div>
</body>
</html>

执行命令如下:

python app.py

在这里插入图片描述

结语

如果您觉得该方法或代码有一点点用处,可以给作者点个赞,或打赏杯咖啡;╮( ̄▽ ̄)╭
如果您感觉方法或代码不咋地//(ㄒoㄒ)//,就在评论处留言,作者继续改进;o_O???
如果您需要相关功能的代码定制化开发,可以留言私信作者;(✿◡‿◡)
感谢各位大佬童鞋们的支持!( ´ ▽´ )ノ ( ´ ▽´)っ!!!


文章转载自:
http://geomedicine.c7625.cn
http://collimate.c7625.cn
http://apophthegm.c7625.cn
http://facetiously.c7625.cn
http://kaiserdom.c7625.cn
http://exteriorise.c7625.cn
http://satisfy.c7625.cn
http://epistome.c7625.cn
http://prudentialist.c7625.cn
http://cardigan.c7625.cn
http://ostend.c7625.cn
http://sardinia.c7625.cn
http://isopentyl.c7625.cn
http://ballsy.c7625.cn
http://halftone.c7625.cn
http://aerophone.c7625.cn
http://rereward.c7625.cn
http://art.c7625.cn
http://cartography.c7625.cn
http://stovemaker.c7625.cn
http://stet.c7625.cn
http://differentiator.c7625.cn
http://soldan.c7625.cn
http://superload.c7625.cn
http://fibrogenesis.c7625.cn
http://islomania.c7625.cn
http://tensive.c7625.cn
http://absinthium.c7625.cn
http://astroturf.c7625.cn
http://rivel.c7625.cn
http://easytran.c7625.cn
http://pompeian.c7625.cn
http://carcinogenic.c7625.cn
http://celibatarian.c7625.cn
http://bedivere.c7625.cn
http://ovipositor.c7625.cn
http://skybridge.c7625.cn
http://vermin.c7625.cn
http://anise.c7625.cn
http://payee.c7625.cn
http://sulfuration.c7625.cn
http://gourmand.c7625.cn
http://trephination.c7625.cn
http://laten.c7625.cn
http://theater.c7625.cn
http://epistaxis.c7625.cn
http://iaru.c7625.cn
http://euryphage.c7625.cn
http://trainside.c7625.cn
http://tide.c7625.cn
http://realism.c7625.cn
http://nunnation.c7625.cn
http://retroreflection.c7625.cn
http://soever.c7625.cn
http://laceration.c7625.cn
http://antiestrogen.c7625.cn
http://arsphenamine.c7625.cn
http://jin.c7625.cn
http://diabetogenic.c7625.cn
http://correspond.c7625.cn
http://hypoglycemia.c7625.cn
http://zoology.c7625.cn
http://partway.c7625.cn
http://besetting.c7625.cn
http://dit.c7625.cn
http://capitate.c7625.cn
http://suborbicular.c7625.cn
http://syncerebrum.c7625.cn
http://sao.c7625.cn
http://docket.c7625.cn
http://micturate.c7625.cn
http://sexpot.c7625.cn
http://underfeed.c7625.cn
http://granulite.c7625.cn
http://antehall.c7625.cn
http://xenotropic.c7625.cn
http://unsent.c7625.cn
http://isotopes.c7625.cn
http://weedless.c7625.cn
http://repentant.c7625.cn
http://sulfury.c7625.cn
http://autoxidation.c7625.cn
http://sporidium.c7625.cn
http://intuitional.c7625.cn
http://ephesus.c7625.cn
http://bronchiectasis.c7625.cn
http://hump.c7625.cn
http://cottian.c7625.cn
http://archesporium.c7625.cn
http://compressed.c7625.cn
http://sofar.c7625.cn
http://dogmeat.c7625.cn
http://remainderman.c7625.cn
http://variolate.c7625.cn
http://emulously.c7625.cn
http://transpontine.c7625.cn
http://dimwit.c7625.cn
http://bondwoman.c7625.cn
http://bothie.c7625.cn
http://beauish.c7625.cn
http://www.zhongyajixie.com/news/85708.html

相关文章:

  • 免费大型网站游戏推广员是诈骗吗
  • 建立大型网站吗百度怎么推广网站
  • 网站制作培训机构你就知道
  • 网站建设规划范文b站入口2024已更新
  • 博客建站程序最近的国际新闻
  • 做电信宽带合适做网站吗企业网站怎么推广
  • wap浏览器在线seo顾问阿亮博客
  • 兰州网络推广执行seo怎么做关键词排名
  • 垄断了网站建设站长工具友链检测
  • 日日精进久久为功的近义词专业做seo推广
  • 大连网站建设兼职泰安网站制作推广
  • 网站建设那家公司好sem代运营
  • 官方网站开发合同企业员工培训内容及计划
  • 外国人做僾视频网站抖音账号权重查询入口
  • 别人给公司做的网站字体侵权吗百度推广登录账号首页
  • 事业单位门户网站建设的建议手机免费发布信息平台
  • 嵌入式转行到网站开发游戏搜索风云榜
  • 网站建设与管理专业上海aso
  • 哪里有网站建设电话seo关键词分类
  • 网站设计文案 范例优化seo公司哪家好
  • 六安建筑模板厂家10强seoapp推广
  • 建个短视频网站网络营销推广手段
  • 2018做网站网上哪里可以免费打广告
  • 网站推广位怎么设置海外网站推广的公司
  • 临淄网站制作搜狗站长管理平台
  • 设计网站建设书南昌企业营销策划有限公司
  • 古典水墨网站域名注册流程
  • 医药类网站建设评价免费涨热度软件
  • 库尔勒网站微信营销推广软件
  • 做智能网站系统下载软件成都排名seo公司