简体   繁体   English

'x_range'散景Gmap错误的值无效

[英]'Invalid value for 'x_range' Bokeh Gmap error

The code below is giving me the following error: 下面的代码给我以下错误:

ValueError: Invalid value for 'x_range', MapPlot ranges may only be Range1d, not data ranges

I'm almost certain there's nothing wrong with the code considering I had it working with no errors up until today. 我几乎可以肯定代码没有问题,因为直到今天我都可以正常工作。

I don't think this is relevant, but it stopped working after I ran the following in my command terminal: 我认为这无关紧要,但是在命令终端中运行以下命令后,它停止了工作:

sudo lsof -t -i tcp:5000 -s tcp:listen | sudo xargs kill

I restarted my computer several times (in hopes of reseting the ports) but that hasn't worked either. 我几次重新启动计算机(以希望重置端口),但这也没有用。

My code is below: 我的代码如下:

from bokeh.models import (
   GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d, PanTool, 
   WheelZoomTool, BoxSelectTool
)
from bokeh.io import output_file, show, output_notebook

output_notebook()


map_options = GMapOptions(lat=30.29, lng=-97.73, map_type="roadmap", zoom=11)

plot = GMapPlot(
x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options
)

plot.title.text = "Austin"


plot.api_key = "INSERT PERSONAL GOOGLE API KEY"


completed_lats = [30.265872,30.2900002]

completed_longs = [-97.749270,-97.733322]

completed_source = ColumnDataSource( data=dict(
    lat=completed_lats,
    lon=completed_longs,))

completed_dots = Circle(x="lon", y="lat", size=50, fill_color="blue",
                        fill_alpha=0.1, line_color=None)
plot.add_glyph(completed_source, completed_dots)


plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())

show(plot)

There is in fact a problem with the code, it is this: 代码实际上存在问题,它是这样的:

plot = GMapPlot(

    x_range=DataRange1d(), y_range=DataRange1d(), # BAD

    map_options=map_options
)

Exactly as the message states, only Range1d can be used with GMapPlot . 与消息状态完全一样,只有Range1d可以与GMapPlot一起使用。 This is because unlike regular Bokeh plots, Google Maps maintains complete control of the plot's axes dimensions. 这是因为与常规的Bokeh图不同,Google Maps可以完全控制图的轴尺寸。 This is inconsistent with using a DataRange1d , because those also try to control the axes dimensions, which can lead to unpredictable and undesirable results. 这与使用DataRange1d不一致,因为它们试图控制轴的尺寸,这可能导致不可预测的不良结果。

There was a time before Bokeh checked for this, and would allow DataRange1d to be passed. 散景检查之前有一段时间,它将允许传递DataRange1d Once it was discovered that combination was causing problems, a check was added to explicitly disallow it. 一旦发现组合引起问题,便添加了检查以明确禁止组合。 You just need to use a Range1d instead (you don't need to set start or end ): 您只需要使用Range1d (无需设置startend ):

plot = GMapPlot(

    x_range=Range1d(), y_range=Range1d(), # GOOD

    map_options=map_options
)

However, I should also point you to the gmap function, which makes creating Google Maps plots much simpler . 但是,我也应该指出gmap函数,该函数使创建Google Maps地图变得更加简单 With that it is much like figure in that a reasonable default plot is created automatically, no need to create and add ranges at all. 与它很像figure在一个合理的默认打印,会自动建立,无需创建并添加范围的。 It was announced in version 0.12.5 . 它在版本0.12.5中宣布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 散景分类 vbar,x_range 不起作用 - bokeh categorical vbar, x_range not working 散景-日期时间 x_range: &#39;ValueError, Unrecognized range input&#39; - Bokeh- datetime x_range: 'ValueError, Unrecognized range input' python 散景动态更新分类 x_range - python bokeh dynamically update categorical x_range 查看散景图 object 上的 x_range 属性? - Viewing x_range attributes on a Bokeh figure object? 基于Bokeh中的x_range自动设置vbar line_width - Auto set vbar line_width based on x_range in Bokeh 如何多次更新散景图中的图特征(悬停工具详细信息和x_range)? - How to update plot characteristics (hovertool details and x_range) in a bokeh plot multiple times? 当在Bokeh中更改链接到另一个图形的另一个图形的x_range时,更改图形中的绘制数据 - Change plotted data in a figure when x_range of another figure linked to the other one is changed in Bokeh 在 x_range 上具有偏移的链接平移 - Linked Panning with offset on x_range 如何使用 Seaborn 误差带显示纯矩阵 [Samples, X_Range] 的误差带? - How to show error bands for pure matrices [Samples, X_Range] with Seaborn error bands? Manim 代码不起作用给出错误“Mobject.getattr。<locals> .getter() 得到了一个意外的关键字参数“x_range”</locals> - Manim code doesn't work gives error "Mobject.getattr.<locals>.getter() got an unexpected keyword argument "x_range"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM