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;








-1















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










share|improve this question


























  • 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


















-1















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










share|improve this question


























  • 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














-1












-1








-1








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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













1 Answer
1






active

oldest

votes


















0














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:



enter image description here






share|improve this answer



























  • It works like a charm. Thank you so much!!

    – N. Arunoprayoch
    Mar 27 at 13:08










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
);



);













draft saved

draft discarded


















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









0














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:



enter image description here






share|improve this answer



























  • It works like a charm. Thank you so much!!

    – N. Arunoprayoch
    Mar 27 at 13:08















0














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:



enter image description here






share|improve this answer



























  • It works like a charm. Thank you so much!!

    – N. Arunoprayoch
    Mar 27 at 13:08













0












0








0







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:



enter image description here






share|improve this answer















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:



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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






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.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해