python - 为什么我看不到使用熊猫散景的两层?
问题描述
我正在尝试按照此处的建议使用pandas_bokeh
import geopandas as gpd
import pandas_bokeh
pandas_bokeh.output_notebook()
# Read in GeoJSONs from URL:
df_states = gpd.read_file(r"https://raw.githubusercontent.com/PatrikHlobil/Pandas-Bokeh/master/Documentation/Testdata/states/states.geojson")
df_cities = gpd.read_file(
r"https://raw.githubusercontent.com/PatrikHlobil/Pandas-Bokeh/master/Documentation/Testdata/populated%20places/ne_10m_populated_places_simple_bigcities.geojson"
)
df_cities["size"] = df_cities.pop_max / 400000
#Plot shapes of US states (pass figure options to this initial plot):
figure = df_states.plot_bokeh(
figsize=(800, 450),
simplify_shapes=10000,
show_figure=False,
xlim=[-170, -80],
ylim=[10, 70],
category="REGION",
colormap="Dark2",
legend="States",
show_colorbar=False,
)
#Plot cities as points on top of the US states layer by passing the figure:
df_cities.plot_bokeh(
figure=figure, # <== pass figure here!
category="pop_max",
colormap="Viridis",
colormap_uselog=True,
size="size",
hovertool_string="""<h1>@name</h1>
<h3>Population: @pop_max </h3>""",
marker="inverted_triangle",
legend="Cities",
)
但是,这是我的输出,其中图层State
不可见
解决方案
这是 Bokeh 1.1 ( https://github.com/PatrikHlobil/Pandas-Bokeh/issues/22 )开始出现的已知错误。在当前的开发版本中,该错误已修复。您可以使用以下方式安装它:
pip install git+https://github.com/PatrikHlobil/Pandas-Bokeh.git
希望这可以解决您的问题。
推荐阅读
- javascript - Javascript等待不等待?
- node.js - 不能向 MongoDB 集合添加超过 1 个对象
- c++ - 如何在 constexpr 中使用 boost 单位前缀
- javascript - Typescript + Next.js 不是类型检查函数参数/参数
- javascript - 点击事件监听器被重复触发而没有任何点击?
- c++ - 错误:“排序”不是“std::ranges”的成员;你的意思是'std :: sort'吗?
- docker - 移动容器内容和重新安装卷
- c++ - 我怎样才能有一个只有错误消息的 static_assert ?
- python - AttributeError:“NoneType”对象没有属性“get_values”
- r - R WebScraping 使用 Rvest 时获取额外的文本