Show one value in range on TooltipHow do I sort a list of dictionaries by a value of the dictionary?How do I return multiple values from a function?How do I sort a dictionary by value?How to access environment variable values?“Large data” work flows using pandashow to show integer, not float, with hover tooltip in bokehWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?Bokeh streaming axesbokeh hover multiline with datetime axisAdd tooltip to Bokeh DataTable
How useful would a hydroelectric power plant be in the post-apocalypse world?
What does this Pokemon Trainer mean by saying the player is "SHELLOS"?
What is my external HDD doing?
Why will we fail creating a self sustaining off world colony?
Advantages of using bra-ket notation
Could you fall off a planet if it was being accelerated by engines?
"nunca" placement after a verb with "no"
What would you need merely the term "collection" for pitches, but not "scale"?
What verb goes with "coup"?
ATMEGA328P-U vs ATMEGA328-PU
Which are more efficient in putting out wildfires: planes or helicopters?
What is this fluorinated organic substance?
Rear derailleur got caught in the spokes, what could be a root cause
Where to connect the fuse and why?
English idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)
Why didn't Avengers simply jump 5 years back?
Find the closest three-digit hex colour
Understanding the as-if rule, "the program was executed as written"
Why are examinees often not allowed to leave during the start and end of an exam?
Why are symbols not written in words?
Enterprise Layers and Naming Conventions
How to track mail undetectably?
Odd PCB Layout for Voltage Regulator
Does "boire un jus" tend to mean "coffee" or "juice of fruit"?
Show one value in range on Tooltip
How do I sort a list of dictionaries by a value of the dictionary?How do I return multiple values from a function?How do I sort a dictionary by value?How to access environment variable values?“Large data” work flows using pandashow to show integer, not float, with hover tooltip in bokehWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?Bokeh streaming axesbokeh hover multiline with datetime axisAdd tooltip to Bokeh DataTable
I am learning to use the Bokeh library on Python. What I have right now is this:
source = ColumnDataSource(data=dict(x=x, counts=rates))
My x
value is an array of tuples, something like this:
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
What I want is to have a tooltip in my graph that will display the second value of the tuple (the 1 or the 2, whichever corresponds). I created my tooltip like this:
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
The first one (Rate) is working fine and shows the value that I want, but the second one shows both values (A, 1) and I only want to show one of them (1). For the record this is how I am creating the figure:
p = figure(x_range=FactorRange(*x), sizing_mode='stretch_both', title="Test",toolbar_location=None, tools="", tooltips=TOOLTIPS)
Is this possible?
python bokeh
add a comment |
I am learning to use the Bokeh library on Python. What I have right now is this:
source = ColumnDataSource(data=dict(x=x, counts=rates))
My x
value is an array of tuples, something like this:
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
What I want is to have a tooltip in my graph that will display the second value of the tuple (the 1 or the 2, whichever corresponds). I created my tooltip like this:
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
The first one (Rate) is working fine and shows the value that I want, but the second one shows both values (A, 1) and I only want to show one of them (1). For the record this is how I am creating the figure:
p = figure(x_range=FactorRange(*x), sizing_mode='stretch_both', title="Test",toolbar_location=None, tools="", tooltips=TOOLTIPS)
Is this possible?
python bokeh
add a comment |
I am learning to use the Bokeh library on Python. What I have right now is this:
source = ColumnDataSource(data=dict(x=x, counts=rates))
My x
value is an array of tuples, something like this:
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
What I want is to have a tooltip in my graph that will display the second value of the tuple (the 1 or the 2, whichever corresponds). I created my tooltip like this:
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
The first one (Rate) is working fine and shows the value that I want, but the second one shows both values (A, 1) and I only want to show one of them (1). For the record this is how I am creating the figure:
p = figure(x_range=FactorRange(*x), sizing_mode='stretch_both', title="Test",toolbar_location=None, tools="", tooltips=TOOLTIPS)
Is this possible?
python bokeh
I am learning to use the Bokeh library on Python. What I have right now is this:
source = ColumnDataSource(data=dict(x=x, counts=rates))
My x
value is an array of tuples, something like this:
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
What I want is to have a tooltip in my graph that will display the second value of the tuple (the 1 or the 2, whichever corresponds). I created my tooltip like this:
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
The first one (Rate) is working fine and shows the value that I want, but the second one shows both values (A, 1) and I only want to show one of them (1). For the record this is how I am creating the figure:
p = figure(x_range=FactorRange(*x), sizing_mode='stretch_both', title="Test",toolbar_location=None, tools="", tooltips=TOOLTIPS)
Is this possible?
python bokeh
python bokeh
asked Mar 25 at 16:33
plasmyplasmy
1342 gold badges5 silver badges19 bronze badges
1342 gold badges5 silver badges19 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can just split the x-array into two separate arrays so that...
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
...becomes...
x_1 = ["A","B","C","A","B","C"]
x_2 = ["1","1","1","2","2","2"]
and then supply these arrays to the CDS.
Then in your tooltip you just reference x_2
like...
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x_2")]
add a comment |
You could use HoverTool callback like this (Bokeh v1.0.4):
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, FactorRange, HoverTool, CustomJS
x = [('A' , '1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
rates = [1, 2, 3, 4, 5, 6]
source = ColumnDataSource(data = dict(x = x, counts = rates))
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
p = figure(x_range = FactorRange(*x), sizing_mode = 'stretch_both', title = "Test", toolbar_location = None, tools = "")
p.vbar(x = 'x', top = 'counts', width = 0.2, source = source)
code = ''' if (cb_data.index.indices.length > 0)
index = cb_data.index.indices[0];
x1 = source.data.x[index][1]
hover.tooltips[1] = ['Value', x1];
'''
hover = HoverTool()
hover.tooltips = TOOLTIPS
hover.callback = CustomJS(args = dict(source = source, hover = hover), code = code)
p.add_tools(hover)
show(p)
Result:
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342442%2fshow-one-value-in-range-on-tooltip%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can just split the x-array into two separate arrays so that...
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
...becomes...
x_1 = ["A","B","C","A","B","C"]
x_2 = ["1","1","1","2","2","2"]
and then supply these arrays to the CDS.
Then in your tooltip you just reference x_2
like...
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x_2")]
add a comment |
You can just split the x-array into two separate arrays so that...
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
...becomes...
x_1 = ["A","B","C","A","B","C"]
x_2 = ["1","1","1","2","2","2"]
and then supply these arrays to the CDS.
Then in your tooltip you just reference x_2
like...
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x_2")]
add a comment |
You can just split the x-array into two separate arrays so that...
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
...becomes...
x_1 = ["A","B","C","A","B","C"]
x_2 = ["1","1","1","2","2","2"]
and then supply these arrays to the CDS.
Then in your tooltip you just reference x_2
like...
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x_2")]
You can just split the x-array into two separate arrays so that...
x = [('A' ,'1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
...becomes...
x_1 = ["A","B","C","A","B","C"]
x_2 = ["1","1","1","2","2","2"]
and then supply these arrays to the CDS.
Then in your tooltip you just reference x_2
like...
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x_2")]
answered Mar 25 at 20:31
Christopher BuhtzChristopher Buhtz
161 bronze badge
161 bronze badge
add a comment |
add a comment |
You could use HoverTool callback like this (Bokeh v1.0.4):
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, FactorRange, HoverTool, CustomJS
x = [('A' , '1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
rates = [1, 2, 3, 4, 5, 6]
source = ColumnDataSource(data = dict(x = x, counts = rates))
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
p = figure(x_range = FactorRange(*x), sizing_mode = 'stretch_both', title = "Test", toolbar_location = None, tools = "")
p.vbar(x = 'x', top = 'counts', width = 0.2, source = source)
code = ''' if (cb_data.index.indices.length > 0)
index = cb_data.index.indices[0];
x1 = source.data.x[index][1]
hover.tooltips[1] = ['Value', x1];
'''
hover = HoverTool()
hover.tooltips = TOOLTIPS
hover.callback = CustomJS(args = dict(source = source, hover = hover), code = code)
p.add_tools(hover)
show(p)
Result:
add a comment |
You could use HoverTool callback like this (Bokeh v1.0.4):
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, FactorRange, HoverTool, CustomJS
x = [('A' , '1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
rates = [1, 2, 3, 4, 5, 6]
source = ColumnDataSource(data = dict(x = x, counts = rates))
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
p = figure(x_range = FactorRange(*x), sizing_mode = 'stretch_both', title = "Test", toolbar_location = None, tools = "")
p.vbar(x = 'x', top = 'counts', width = 0.2, source = source)
code = ''' if (cb_data.index.indices.length > 0)
index = cb_data.index.indices[0];
x1 = source.data.x[index][1]
hover.tooltips[1] = ['Value', x1];
'''
hover = HoverTool()
hover.tooltips = TOOLTIPS
hover.callback = CustomJS(args = dict(source = source, hover = hover), code = code)
p.add_tools(hover)
show(p)
Result:
add a comment |
You could use HoverTool callback like this (Bokeh v1.0.4):
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, FactorRange, HoverTool, CustomJS
x = [('A' , '1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
rates = [1, 2, 3, 4, 5, 6]
source = ColumnDataSource(data = dict(x = x, counts = rates))
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
p = figure(x_range = FactorRange(*x), sizing_mode = 'stretch_both', title = "Test", toolbar_location = None, tools = "")
p.vbar(x = 'x', top = 'counts', width = 0.2, source = source)
code = ''' if (cb_data.index.indices.length > 0)
index = cb_data.index.indices[0];
x1 = source.data.x[index][1]
hover.tooltips[1] = ['Value', x1];
'''
hover = HoverTool()
hover.tooltips = TOOLTIPS
hover.callback = CustomJS(args = dict(source = source, hover = hover), code = code)
p.add_tools(hover)
show(p)
Result:
You could use HoverTool callback like this (Bokeh v1.0.4):
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, FactorRange, HoverTool, CustomJS
x = [('A' , '1'), ('B', '1'), ('C', '1'), ('A', '2'), ('B', '2'), ('C', '2')]
rates = [1, 2, 3, 4, 5, 6]
source = ColumnDataSource(data = dict(x = x, counts = rates))
TOOLTIPS = [("Rate", "@counts"), ("Value", "@x")]
p = figure(x_range = FactorRange(*x), sizing_mode = 'stretch_both', title = "Test", toolbar_location = None, tools = "")
p.vbar(x = 'x', top = 'counts', width = 0.2, source = source)
code = ''' if (cb_data.index.indices.length > 0)
index = cb_data.index.indices[0];
x1 = source.data.x[index][1]
hover.tooltips[1] = ['Value', x1];
'''
hover = HoverTool()
hover.tooltips = TOOLTIPS
hover.callback = CustomJS(args = dict(source = source, hover = hover), code = code)
p.add_tools(hover)
show(p)
Result:
answered Mar 25 at 23:51
TonyTony
2,8941 gold badge5 silver badges22 bronze badges
2,8941 gold badge5 silver badges22 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342442%2fshow-one-value-in-range-on-tooltip%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown