How to set bar-chart hover to show x axis' labels?Python, Matplotlib, subplot: How to set the axis range?setting y-axis limit in matplotlibTimeSeries as a box plot with BokehSeaborn: countplot() with frequenciesFormatting in HoverToolHow to add data labels to a bar chart in Bokeh?Hover tool not working in BokehLabel stacked bar with autolabel functionDoes Bokeh require a ColumnDataSource and a Hover tool for each graph you want to display?Bokeh+Flask: Multiple AjaxDataSource calls
Physics of Guitar frets and sound
Can a PC attack themselves with an unarmed strike?
Decode a variable-length quantity
How do I calculate the difference in lens reach between a superzoom compact and a DSLR zoom lens?
How do I change the output voltage of the LM7805?
Does a code snippet compile? Or does it gets compiled?
How to translate this word-play with the word "bargain" into French?
How to execute python script by terminal?
Why should public servants be apolitical?
Does two puncture wounds mean venomous snake?
Double blind peer review when paper cites author's GitHub repo for code
Why is it 'in the saddle' rather than 'on the saddle'?
Validation and verification of mathematical models
Blocking people from taking pictures of me with smartphone
Does this Foo machine halt?
During the Space Shuttle Columbia Disaster of 2003, Why Did The Flight Director Say, "Lock the doors."?
What would happen to an adventurer's personal identity when turning into a God?
Is the beaming of this score following a vocal practice or it is just outdated and obscuring the beat?
How to display a duet in lyrics?
In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?
New computer from Dell with pre-installed Ubuntu won't boot. Should I assume it's an error from Dell?
Generator for parity?
How do we avoid CI-driven development...?
Why couldn't soldiers sight their own weapons without officers' orders?
How to set bar-chart hover to show x axis' labels?
Python, Matplotlib, subplot: How to set the axis range?setting y-axis limit in matplotlibTimeSeries as a box plot with BokehSeaborn: countplot() with frequenciesFormatting in HoverToolHow to add data labels to a bar chart in Bokeh?Hover tool not working in BokehLabel stacked bar with autolabel functionDoes Bokeh require a ColumnDataSource and a Hover tool for each graph you want to display?Bokeh+Flask: Multiple AjaxDataSource calls
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have generated a simple bar chart. In order to make it more interactive, I have added Hovertool into the graph.
from bokeh.io import show, output_notebook
from bokeh.plotting import figure, output_file
from bokeh.models.glyphs import HBar
from bokeh.models import ColumnDataSource, Legend, HoverTool
output_notebook()
# Set x and y
functions = ['func_1', 'func_2', 'func_3']
percentage = [233.14, 312.03, 234.00]
# Set data source (color needs to be set precisely with len(category))
source = ColumnDataSource(data=dict(functions=functions, percentage=percentage))
# Set the x_range to the list of categories above
p = figure(x_range=functions, plot_height=600, plot_width=800, title="The Overall Use of my functions",
x_axis_label='Functions', y_axis_label='Percentage')
# Categorical values can also be used as coordinates
p.vbar(x='functions', top='percentage', width=0.9, source=source)
p.add_tools(HoverTool(tooltips=[('Percentage', "@percentage")]))
show(p)
Although it shows a value from y axis correctly, I would like to display a label from x axis instead (e.g., Func1: 9.45). Just like the picture that is shown from the link (I cannot post an image yet):
https://i.ibb.co/235jR39/Untitled.png
Update#1
I tried to come up with something, this is what I got:
# Set Hover
percentage = list(map(lambda i: str(i), percentage))
my_hover = list(zip(functions, percentage))
p.add_tools(HoverTool(tooltips=my_hover))
It turns out it shows every detail in every bar as shown below
https://i.ibb.co/72hmD8q/Untitled-2.png
python bokeh
add a comment |
I have generated a simple bar chart. In order to make it more interactive, I have added Hovertool into the graph.
from bokeh.io import show, output_notebook
from bokeh.plotting import figure, output_file
from bokeh.models.glyphs import HBar
from bokeh.models import ColumnDataSource, Legend, HoverTool
output_notebook()
# Set x and y
functions = ['func_1', 'func_2', 'func_3']
percentage = [233.14, 312.03, 234.00]
# Set data source (color needs to be set precisely with len(category))
source = ColumnDataSource(data=dict(functions=functions, percentage=percentage))
# Set the x_range to the list of categories above
p = figure(x_range=functions, plot_height=600, plot_width=800, title="The Overall Use of my functions",
x_axis_label='Functions', y_axis_label='Percentage')
# Categorical values can also be used as coordinates
p.vbar(x='functions', top='percentage', width=0.9, source=source)
p.add_tools(HoverTool(tooltips=[('Percentage', "@percentage")]))
show(p)
Although it shows a value from y axis correctly, I would like to display a label from x axis instead (e.g., Func1: 9.45). Just like the picture that is shown from the link (I cannot post an image yet):
https://i.ibb.co/235jR39/Untitled.png
Update#1
I tried to come up with something, this is what I got:
# Set Hover
percentage = list(map(lambda i: str(i), percentage))
my_hover = list(zip(functions, percentage))
p.add_tools(HoverTool(tooltips=my_hover))
It turns out it shows every detail in every bar as shown below
https://i.ibb.co/72hmD8q/Untitled-2.png
python bokeh
Is your data for functions a list with values or with tuples? (btw: please always post a minimal but runnable code) Could you add a small (representative) part of that data to your example?
– Tony
Mar 27 at 8:49
@Tony Basically, it would look like this functions = ['func_1', 'func_2',.....n] percentage = [123, 342, .....n]
– N. Arunoprayoch
Mar 27 at 12:08
add a comment |
I have generated a simple bar chart. In order to make it more interactive, I have added Hovertool into the graph.
from bokeh.io import show, output_notebook
from bokeh.plotting import figure, output_file
from bokeh.models.glyphs import HBar
from bokeh.models import ColumnDataSource, Legend, HoverTool
output_notebook()
# Set x and y
functions = ['func_1', 'func_2', 'func_3']
percentage = [233.14, 312.03, 234.00]
# Set data source (color needs to be set precisely with len(category))
source = ColumnDataSource(data=dict(functions=functions, percentage=percentage))
# Set the x_range to the list of categories above
p = figure(x_range=functions, plot_height=600, plot_width=800, title="The Overall Use of my functions",
x_axis_label='Functions', y_axis_label='Percentage')
# Categorical values can also be used as coordinates
p.vbar(x='functions', top='percentage', width=0.9, source=source)
p.add_tools(HoverTool(tooltips=[('Percentage', "@percentage")]))
show(p)
Although it shows a value from y axis correctly, I would like to display a label from x axis instead (e.g., Func1: 9.45). Just like the picture that is shown from the link (I cannot post an image yet):
https://i.ibb.co/235jR39/Untitled.png
Update#1
I tried to come up with something, this is what I got:
# Set Hover
percentage = list(map(lambda i: str(i), percentage))
my_hover = list(zip(functions, percentage))
p.add_tools(HoverTool(tooltips=my_hover))
It turns out it shows every detail in every bar as shown below
https://i.ibb.co/72hmD8q/Untitled-2.png
python bokeh
I have generated a simple bar chart. In order to make it more interactive, I have added Hovertool into the graph.
from bokeh.io import show, output_notebook
from bokeh.plotting import figure, output_file
from bokeh.models.glyphs import HBar
from bokeh.models import ColumnDataSource, Legend, HoverTool
output_notebook()
# Set x and y
functions = ['func_1', 'func_2', 'func_3']
percentage = [233.14, 312.03, 234.00]
# Set data source (color needs to be set precisely with len(category))
source = ColumnDataSource(data=dict(functions=functions, percentage=percentage))
# Set the x_range to the list of categories above
p = figure(x_range=functions, plot_height=600, plot_width=800, title="The Overall Use of my functions",
x_axis_label='Functions', y_axis_label='Percentage')
# Categorical values can also be used as coordinates
p.vbar(x='functions', top='percentage', width=0.9, source=source)
p.add_tools(HoverTool(tooltips=[('Percentage', "@percentage")]))
show(p)
Although it shows a value from y axis correctly, I would like to display a label from x axis instead (e.g., Func1: 9.45). Just like the picture that is shown from the link (I cannot post an image yet):
https://i.ibb.co/235jR39/Untitled.png
Update#1
I tried to come up with something, this is what I got:
# Set Hover
percentage = list(map(lambda i: str(i), percentage))
my_hover = list(zip(functions, percentage))
p.add_tools(HoverTool(tooltips=my_hover))
It turns out it shows every detail in every bar as shown below
https://i.ibb.co/72hmD8q/Untitled-2.png
python bokeh
python bokeh
edited Mar 27 at 12:12
N. Arunoprayoch
asked Mar 27 at 6:56
N. ArunoprayochN. Arunoprayoch
4083 silver badges12 bronze badges
4083 silver badges12 bronze badges
Is your data for functions a list with values or with tuples? (btw: please always post a minimal but runnable code) Could you add a small (representative) part of that data to your example?
– Tony
Mar 27 at 8:49
@Tony Basically, it would look like this functions = ['func_1', 'func_2',.....n] percentage = [123, 342, .....n]
– N. Arunoprayoch
Mar 27 at 12:08
add a comment |
Is your data for functions a list with values or with tuples? (btw: please always post a minimal but runnable code) Could you add a small (representative) part of that data to your example?
– Tony
Mar 27 at 8:49
@Tony Basically, it would look like this functions = ['func_1', 'func_2',.....n] percentage = [123, 342, .....n]
– N. Arunoprayoch
Mar 27 at 12:08
Is your data for functions a list with values or with tuples? (btw: please always post a minimal but runnable code) Could you add a small (representative) part of that data to your example?
– Tony
Mar 27 at 8:49
Is your data for functions a list with values or with tuples? (btw: please always post a minimal but runnable code) Could you add a small (representative) part of that data to your example?
– Tony
Mar 27 at 8:49
@Tony Basically, it would look like this functions = ['func_1', 'func_2',.....n] percentage = [123, 342, .....n]
– N. Arunoprayoch
Mar 27 at 12:08
@Tony Basically, it would look like this functions = ['func_1', 'func_2',.....n] percentage = [123, 342, .....n]
– N. Arunoprayoch
Mar 27 at 12:08
add a comment |
1 Answer
1
active
oldest
votes
This code works for Bokeh v1.0.4.
import math
import numpy as np
import pandas as pd
from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import figure, show
from bokeh.palettes import Category10
df = pd.DataFrame(data = np.random.rand(10, 1), columns = ['percentage'], index = ['Func '.format(nmb) for nmb in range(10)])
df['color'] = Category10[10]
source = ColumnDataSource(data = dict(functions = df.index.values, percentage = df['percentage'].values, color = df['color'].values))
p = figure(x_range = df.index.values, plot_height = 600, plot_width = 800, title = "The Overall Use of my functions",
x_axis_label = 'functions', y_axis_label = 'percentage')
p.vbar(x = 'functions', top = 'percentage', width = 0.9, color = 'color', source = source)
p.add_tools(HoverTool(tooltips = '<font color=blue>@functions:</font><font color=red> @percentage</font>'))
p.xgrid.grid_line_color = None
p.xaxis.major_label_orientation = math.pi / 4 # Rotate axis' labels
show(p)
Result:

It works like a charm. Thank you so much!!
– N. Arunoprayoch
Mar 27 at 13:08
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%2f55371407%2fhow-to-set-bar-chart-hover-to-show-x-axis-labels%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This code works for Bokeh v1.0.4.
import math
import numpy as np
import pandas as pd
from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import figure, show
from bokeh.palettes import Category10
df = pd.DataFrame(data = np.random.rand(10, 1), columns = ['percentage'], index = ['Func '.format(nmb) for nmb in range(10)])
df['color'] = Category10[10]
source = ColumnDataSource(data = dict(functions = df.index.values, percentage = df['percentage'].values, color = df['color'].values))
p = figure(x_range = df.index.values, plot_height = 600, plot_width = 800, title = "The Overall Use of my functions",
x_axis_label = 'functions', y_axis_label = 'percentage')
p.vbar(x = 'functions', top = 'percentage', width = 0.9, color = 'color', source = source)
p.add_tools(HoverTool(tooltips = '<font color=blue>@functions:</font><font color=red> @percentage</font>'))
p.xgrid.grid_line_color = None
p.xaxis.major_label_orientation = math.pi / 4 # Rotate axis' labels
show(p)
Result:

It works like a charm. Thank you so much!!
– N. Arunoprayoch
Mar 27 at 13:08
add a comment |
This code works for Bokeh v1.0.4.
import math
import numpy as np
import pandas as pd
from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import figure, show
from bokeh.palettes import Category10
df = pd.DataFrame(data = np.random.rand(10, 1), columns = ['percentage'], index = ['Func '.format(nmb) for nmb in range(10)])
df['color'] = Category10[10]
source = ColumnDataSource(data = dict(functions = df.index.values, percentage = df['percentage'].values, color = df['color'].values))
p = figure(x_range = df.index.values, plot_height = 600, plot_width = 800, title = "The Overall Use of my functions",
x_axis_label = 'functions', y_axis_label = 'percentage')
p.vbar(x = 'functions', top = 'percentage', width = 0.9, color = 'color', source = source)
p.add_tools(HoverTool(tooltips = '<font color=blue>@functions:</font><font color=red> @percentage</font>'))
p.xgrid.grid_line_color = None
p.xaxis.major_label_orientation = math.pi / 4 # Rotate axis' labels
show(p)
Result:

It works like a charm. Thank you so much!!
– N. Arunoprayoch
Mar 27 at 13:08
add a comment |
This code works for Bokeh v1.0.4.
import math
import numpy as np
import pandas as pd
from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import figure, show
from bokeh.palettes import Category10
df = pd.DataFrame(data = np.random.rand(10, 1), columns = ['percentage'], index = ['Func '.format(nmb) for nmb in range(10)])
df['color'] = Category10[10]
source = ColumnDataSource(data = dict(functions = df.index.values, percentage = df['percentage'].values, color = df['color'].values))
p = figure(x_range = df.index.values, plot_height = 600, plot_width = 800, title = "The Overall Use of my functions",
x_axis_label = 'functions', y_axis_label = 'percentage')
p.vbar(x = 'functions', top = 'percentage', width = 0.9, color = 'color', source = source)
p.add_tools(HoverTool(tooltips = '<font color=blue>@functions:</font><font color=red> @percentage</font>'))
p.xgrid.grid_line_color = None
p.xaxis.major_label_orientation = math.pi / 4 # Rotate axis' labels
show(p)
Result:

This code works for Bokeh v1.0.4.
import math
import numpy as np
import pandas as pd
from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import figure, show
from bokeh.palettes import Category10
df = pd.DataFrame(data = np.random.rand(10, 1), columns = ['percentage'], index = ['Func '.format(nmb) for nmb in range(10)])
df['color'] = Category10[10]
source = ColumnDataSource(data = dict(functions = df.index.values, percentage = df['percentage'].values, color = df['color'].values))
p = figure(x_range = df.index.values, plot_height = 600, plot_width = 800, title = "The Overall Use of my functions",
x_axis_label = 'functions', y_axis_label = 'percentage')
p.vbar(x = 'functions', top = 'percentage', width = 0.9, color = 'color', source = source)
p.add_tools(HoverTool(tooltips = '<font color=blue>@functions:</font><font color=red> @percentage</font>'))
p.xgrid.grid_line_color = None
p.xaxis.major_label_orientation = math.pi / 4 # Rotate axis' labels
show(p)
Result:

edited Mar 27 at 12:40
answered Mar 27 at 12:34
TonyTony
2,9491 gold badge5 silver badges22 bronze badges
2,9491 gold badge5 silver badges22 bronze badges
It works like a charm. Thank you so much!!
– N. Arunoprayoch
Mar 27 at 13:08
add a comment |
It works like a charm. Thank you so much!!
– N. Arunoprayoch
Mar 27 at 13:08
It works like a charm. Thank you so much!!
– N. Arunoprayoch
Mar 27 at 13:08
It works like a charm. Thank you so much!!
– N. Arunoprayoch
Mar 27 at 13:08
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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%2f55371407%2fhow-to-set-bar-chart-hover-to-show-x-axis-labels%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
Is your data for functions a list with values or with tuples? (btw: please always post a minimal but runnable code) Could you add a small (representative) part of that data to your example?
– Tony
Mar 27 at 8:49
@Tony Basically, it would look like this functions = ['func_1', 'func_2',.....n] percentage = [123, 342, .....n]
– N. Arunoprayoch
Mar 27 at 12:08