R ggplot plotly mouseover tooltip not working. Error: undefined columns selectedToolTip when you mouseover a ggplot on shinyChange axis title position in ggplot using plotlyChange colour of ggplot interactively with plotlyPlotly and stat_summary produce “NA” in tooltipR: ggplot, plotly and auto-adjust of a Stacked bar plotInteractive plot R within dplyr ggplot plotlyIndividual curves according to class. From ggplot to plotlyplotly subplot with ggplot and grouped legend?Duplicate hover info in plotly when converting ggplot to plotlyTooltip for lines with ggplot and ggplotly
Boss wants me to falsify a report. How should I document this unethical demand?
What is the recommended way to have two characters speak simultaneously?
I think I may have violated academic integrity last year - what should I do?
Identify this in soil?
Flying domestically in the US, is my State Issued ID all I need to get past security?
Under what law can the U.S. arrest International Criminal Court (ICC) judges over war crimes probe?
Mother abusing my finances
Line of lights moving in a straight line , with a few following
Could a 19.25mm revolver actually exist?
Employer asking for online access to bank account - Is this a scam?
Is the Starlink array really visible from Earth?
What is the object moving across the ceiling in this stock footage?
Newly created fields are not being displayed
Passing arguments from TeX to a Lua function
Wireless Multipoint Bridging / Backhaul Gateway Antenna and AP Selection
Pirate democracy at its finest
Is cutting a DIY spline channel around the openings of our wood screen porch a dumb idea?
Passively reducing ground loss?
Placing bypass capacitors after VCC reaches the IC
Should I disclose a colleague's illness (that I should not know about) when others badmouth him
Does linking adjectives allow you to talk about multiple variations of something?
Is it possible to play as a necromancer skeleton?
How are glycosidic linkages formed?
Are these reasonable traits for someone with autism?
R ggplot plotly mouseover tooltip not working. Error: undefined columns selected
ToolTip when you mouseover a ggplot on shinyChange axis title position in ggplot using plotlyChange colour of ggplot interactively with plotlyPlotly and stat_summary produce “NA” in tooltipR: ggplot, plotly and auto-adjust of a Stacked bar plotInteractive plot R within dplyr ggplot plotlyIndividual curves according to class. From ggplot to plotlyplotly subplot with ggplot and grouped legend?Duplicate hover info in plotly when converting ggplot to plotlyTooltip for lines with ggplot and ggplotly
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to plot and use ggplotly for mouseover in geom_point objects.
Here is my reproducible R script:
require(ggplot2)
library(ggrepel)
library(plotly)
# Create the data frame.
sales_data <- data.frame(
emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 2),
month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 2)),
dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 2)),
revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 2),
status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 2)
)
sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"))
month_vector <- levels(sales_data$month)
number_of_enteries <- nrow(sales_data)
sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"))
sales_data$month <- as.integer(sales_data$month)
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point(aes(size = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
#ggplotly(myChart)
myChart
It gives me error:
Error in
[.data.frame(g, , c("fill_plotlyDomain", "fill")) :
undefined columns selected
It plots correctly if I comment ggplotly(myChart) and uncomment myChart
Here is output chart:

Any suggestion or help, how I can see revenue data and few other details in tooltip on mouseover ?
Thanks in Advance!
r ggplot2 ggplotly
add a comment |
I am trying to plot and use ggplotly for mouseover in geom_point objects.
Here is my reproducible R script:
require(ggplot2)
library(ggrepel)
library(plotly)
# Create the data frame.
sales_data <- data.frame(
emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 2),
month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 2)),
dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 2)),
revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 2),
status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 2)
)
sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"))
month_vector <- levels(sales_data$month)
number_of_enteries <- nrow(sales_data)
sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"))
sales_data$month <- as.integer(sales_data$month)
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point(aes(size = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
#ggplotly(myChart)
myChart
It gives me error:
Error in
[.data.frame(g, , c("fill_plotlyDomain", "fill")) :
undefined columns selected
It plots correctly if I comment ggplotly(myChart) and uncomment myChart
Here is output chart:

Any suggestion or help, how I can see revenue data and few other details in tooltip on mouseover ?
Thanks in Advance!
r ggplot2 ggplotly
add a comment |
I am trying to plot and use ggplotly for mouseover in geom_point objects.
Here is my reproducible R script:
require(ggplot2)
library(ggrepel)
library(plotly)
# Create the data frame.
sales_data <- data.frame(
emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 2),
month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 2)),
dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 2)),
revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 2),
status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 2)
)
sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"))
month_vector <- levels(sales_data$month)
number_of_enteries <- nrow(sales_data)
sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"))
sales_data$month <- as.integer(sales_data$month)
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point(aes(size = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
#ggplotly(myChart)
myChart
It gives me error:
Error in
[.data.frame(g, , c("fill_plotlyDomain", "fill")) :
undefined columns selected
It plots correctly if I comment ggplotly(myChart) and uncomment myChart
Here is output chart:

Any suggestion or help, how I can see revenue data and few other details in tooltip on mouseover ?
Thanks in Advance!
r ggplot2 ggplotly
I am trying to plot and use ggplotly for mouseover in geom_point objects.
Here is my reproducible R script:
require(ggplot2)
library(ggrepel)
library(plotly)
# Create the data frame.
sales_data <- data.frame(
emp_name = rep(c("Sam", "Dave", "John", "Harry", "Clark", "Kent", "Kenneth", "Richard", "Clement", "Toby", "Jonathan"), times = 2),
month = as.factor(rep(c("Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Feb", "Mar", "Jan", "Jan"), times = 2)),
dept_name = as.factor(rep(c("Production", "Services", "Support", "Support", "Services", "Production", "Production", "Support", "Support", "Support", "Production"), times = 2)),
revenue = rep(c(100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 500), times = 2),
status = rep(c("Low", "Medium", "Medium", "High", "Very High", "Very High", "Very High", "High", "Medium", "Medium", "Low"), times = 2)
)
sales_data$month <- factor(sales_data$month, levels = c("Jan", "Feb", "Mar"))
month_vector <- levels(sales_data$month)
number_of_enteries <- nrow(sales_data)
sales_data$status <- factor(sales_data$status, levels = c("Low", "Medium", "High", "Very High"))
sales_data$month <- as.integer(sales_data$month)
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point(aes(size = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
#ggplotly(myChart)
myChart
It gives me error:
Error in
[.data.frame(g, , c("fill_plotlyDomain", "fill")) :
undefined columns selected
It plots correctly if I comment ggplotly(myChart) and uncomment myChart
Here is output chart:

Any suggestion or help, how I can see revenue data and few other details in tooltip on mouseover ?
Thanks in Advance!
r ggplot2 ggplotly
r ggplot2 ggplotly
edited Mar 24 at 7:28
Om Prakash Sao
asked Mar 24 at 6:50
Om Prakash SaoOm Prakash Sao
1,5211330
1,5211330
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There is ggiraph (https://davidgohel.github.io/ggiraph/articles/offcran/using_ggiraph.html) but since I do not know what you desire to show when mousing over, I can only provide a incomplete version:
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point_interactive(aes(tooltip = status, data_id = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
library(ggiraph)
ggiraph(myChart2)
girafe(code = print(myChart) )
Thanks @LocoGris for answer. But withoutgeom_rastermy plot will be meaningless. Other thanplotly, are there any ways to show tooltip ?
– Om Prakash Sao
Mar 24 at 16:15
ggiraph is also available. I edited my answer
– LocoGris
Mar 24 at 16:30
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%2f55321392%2fr-ggplot-plotly-mouseover-tooltip-not-working-error-undefined-columns-selected%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
There is ggiraph (https://davidgohel.github.io/ggiraph/articles/offcran/using_ggiraph.html) but since I do not know what you desire to show when mousing over, I can only provide a incomplete version:
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point_interactive(aes(tooltip = status, data_id = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
library(ggiraph)
ggiraph(myChart2)
girafe(code = print(myChart) )
Thanks @LocoGris for answer. But withoutgeom_rastermy plot will be meaningless. Other thanplotly, are there any ways to show tooltip ?
– Om Prakash Sao
Mar 24 at 16:15
ggiraph is also available. I edited my answer
– LocoGris
Mar 24 at 16:30
add a comment |
There is ggiraph (https://davidgohel.github.io/ggiraph/articles/offcran/using_ggiraph.html) but since I do not know what you desire to show when mousing over, I can only provide a incomplete version:
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point_interactive(aes(tooltip = status, data_id = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
library(ggiraph)
ggiraph(myChart2)
girafe(code = print(myChart) )
Thanks @LocoGris for answer. But withoutgeom_rastermy plot will be meaningless. Other thanplotly, are there any ways to show tooltip ?
– Om Prakash Sao
Mar 24 at 16:15
ggiraph is also available. I edited my answer
– LocoGris
Mar 24 at 16:30
add a comment |
There is ggiraph (https://davidgohel.github.io/ggiraph/articles/offcran/using_ggiraph.html) but since I do not know what you desire to show when mousing over, I can only provide a incomplete version:
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point_interactive(aes(tooltip = status, data_id = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
library(ggiraph)
ggiraph(myChart2)
girafe(code = print(myChart) )
There is ggiraph (https://davidgohel.github.io/ggiraph/articles/offcran/using_ggiraph.html) but since I do not know what you desire to show when mousing over, I can only provide a incomplete version:
myChart <- ggplot(sales_data, aes(x = month, y = dept_name)) +
geom_raster(data = expand.grid(sales_data$month, sales_data$dept_name),
aes(x = Var1, y = Var2, width=1, height=1), fill = NA, col = 'gray50', lty = 1) + #default width and height is 1
geom_point_interactive(aes(tooltip = status, data_id = status, colour = cut(revenue, c(-Inf, 199, 301, Inf)) ),
shape = 16, position = position_jitter(seed = 0), show.legend = F) +
scale_color_manual(name = "revenue",
values = c("(-Inf,199]" = "red",
"(199,301]" = "#ffbf00", #amber
"(301, Inf]" = "green") ) +
geom_text(aes(label = revenue), size=4, vjust = 1.6, position = position_jitter(seed = 0)) + #try with geom_text
theme_bw() +
theme(
axis.title = element_blank(),
axis.ticks = element_blank(),
plot.background = element_blank(),
axis.line = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
axis.text = element_text(colour = "blue", face = "plain", size =11)
) +
scale_x_continuous(limits=c(0.5,3.5), expand = c(0,0), breaks = 1:length(month_vector), labels = month_vector) +
scale_y_discrete(expand = c(0,0)) +
geom_hline(yintercept = as.numeric(sales_data$dept_name) + 0.5) +
geom_vline(xintercept = as.numeric(sales_data$month) - 0.5, color = "grey")
library(ggiraph)
ggiraph(myChart2)
girafe(code = print(myChart) )
edited Mar 24 at 16:29
answered Mar 24 at 15:51
LocoGrisLocoGris
2,83821028
2,83821028
Thanks @LocoGris for answer. But withoutgeom_rastermy plot will be meaningless. Other thanplotly, are there any ways to show tooltip ?
– Om Prakash Sao
Mar 24 at 16:15
ggiraph is also available. I edited my answer
– LocoGris
Mar 24 at 16:30
add a comment |
Thanks @LocoGris for answer. But withoutgeom_rastermy plot will be meaningless. Other thanplotly, are there any ways to show tooltip ?
– Om Prakash Sao
Mar 24 at 16:15
ggiraph is also available. I edited my answer
– LocoGris
Mar 24 at 16:30
Thanks @LocoGris for answer. But without
geom_raster my plot will be meaningless. Other than plotly, are there any ways to show tooltip ?– Om Prakash Sao
Mar 24 at 16:15
Thanks @LocoGris for answer. But without
geom_raster my plot will be meaningless. Other than plotly, are there any ways to show tooltip ?– Om Prakash Sao
Mar 24 at 16:15
ggiraph is also available. I edited my answer
– LocoGris
Mar 24 at 16:30
ggiraph is also available. I edited my answer
– LocoGris
Mar 24 at 16:30
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%2f55321392%2fr-ggplot-plotly-mouseover-tooltip-not-working-error-undefined-columns-selected%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