Python 如果图形x#U范围为';什么是字符串列表?

Python 如果图形x#U范围为';什么是字符串列表?,python,bokeh,Python,Bokeh,我想改变bokeh图的x轴 xrange = ["Marseille", "Lyon"] plot = figure(x_range=xrange) plotSource = ColumnDataSource(data=dict(x=xrange, y=[1, 2])) bars = VBar(x="x", top="y", width=0.1, fill_color="black") plot.add_glyph(plotSource, bars) handler = show(pl

我想改变bokeh图的x轴

xrange = ["Marseille", "Lyon"]

plot = figure(x_range=xrange)

plotSource = ColumnDataSource(data=dict(x=xrange, y=[1, 2]))

bars = VBar(x="x", top="y", width=0.1, fill_color="black")

plot.add_glyph(plotSource, bars)

handler = show(plot, notebook_handle=True)

plot.x_range = ["Marseille", "Paris"]  # how can i do that

push_notebook(handle=handler)

我无法从列表中创建范围,我该怎么做?

您已经在figure构造函数中设置了
x\u范围
,稍后您将尝试设置两次。但是你应该使用
plot.x_range.factors=[“马赛”、“巴黎”]

或者这可能是您想要的更简单的代码(使用
源代码)


您已经在figure构造函数中设置了
x_范围
,以后将尝试设置两次。但是你应该使用
plot.x_range.factors=[“马赛”、“巴黎”]

或者这可能是您想要的更简单的代码(使用
源代码)


预期的结果是什么?我认为您正在寻找一种更改轴刻度值的方法。如果是这样,看看这个线程预期的结果是什么?我认为您正在寻找一种方法来更改轴刻度值。如果是这样的话,看看这条线
ValueError: expected an instance of type Range, got ['Marseille', 'Paris'] of type list
from bokeh.plotting import show, figure
from bokeh.models import ColumnDataSource, VBar

xrange = ["Marseille", "Lyon"]
plot = figure(x_range = xrange)
plotSource = ColumnDataSource(data = dict(x = xrange, y = [1, 2]))
bars = VBar(x = "x", top = "y", width = 0.1, fill_color = "black")
plot.add_glyph(plotSource, bars)
handler = show(plot, notebook_handle = True)

plot.x_range.factors = ["Marseille", "Paris"]

show(plot)
from bokeh.plotting import show, figure
from bokeh.models import ColumnDataSource

xrange = ["Marseille", "Lyon"]
p = figure(x_range = xrange)
source = ColumnDataSource(data = dict(x = xrange, y = [1, 2]))
bars = p.vbar(x = "x", top = "y", source = source, width = 0.1, fill_color = "black")

show(p)