ggplotly

Format numbers on axes and tooltips in ggplotly

▼魔方 西西 提交于 2021-02-17 04:52:07
问题 I have used sprintf and formatC to take a double value and round it to two decimal places. However, when I go to use it in ggplot and ggplotly, it makes my visuals act out. Dput: structure(list(Date = structure(c(18328, 18329, 18330, 18331, 18332, 18333), class = "Date"), State = c("Louisiana", "Louisiana", "Louisiana", "Louisiana", "Louisiana", "Louisiana"), variablename1 = c(0, 0, 1, 1, 6, 14), variablename2 = c(5, 5, 5, 11, 37, 37), death = c(0, 0, 0, 0, 0, 0), variablename3 = c(5, 5, 6,

How to control “count” in tooltip for ggplotly with filled bar plot in R

泄露秘密 提交于 2021-02-11 18:01:46
问题 Thanks in advance for any advice you can offer! I'm hoping to be able to relabel "count" in the tooltip for a public facing interactive plot. Here's a reproducible example: library(plotly) df <- data.frame(cat=c(rep("A", 5), rep("B", 7), rep("C", 10)), time=c(rep("Time1", 3), rep("Time2", 13), rep("Time3", 6))) ggplotly(ggplot(df, aes(x=time, fill=cat)) + geom_bar(position = "fill")) I know I can control the time and category labels in the tooltip with text=paste("Category:", cat, "Time:"

How to control “count” in tooltip for ggplotly with filled bar plot in R

浪尽此生 提交于 2021-02-11 18:01:05
问题 Thanks in advance for any advice you can offer! I'm hoping to be able to relabel "count" in the tooltip for a public facing interactive plot. Here's a reproducible example: library(plotly) df <- data.frame(cat=c(rep("A", 5), rep("B", 7), rep("C", 10)), time=c(rep("Time1", 3), rep("Time2", 13), rep("Time3", 6))) ggplotly(ggplot(df, aes(x=time, fill=cat)) + geom_bar(position = "fill")) I know I can control the time and category labels in the tooltip with text=paste("Category:", cat, "Time:"

ggplotly and multiple highlight functions

时光总嘲笑我的痴心妄想 提交于 2021-02-07 10:31:15
问题 How can I use two or more highlight functions on a ggplotly object. In the following example I want to highlight the hovered bar in black the clicked bar in blue When using 2 highlight functions, only the last one is used and it obviously overwrites the previous one. So how can I define different behaviour for click and hover-events? Data: dnew <- {structure(list(time_stamp = structure(c(1514761200, 1514847600, 1514934000, 1515020400, 1515106800, 1515193200, 1515279600, 1515366000, 1515452400

ggplotly and multiple highlight functions

柔情痞子 提交于 2021-02-07 10:31:12
问题 How can I use two or more highlight functions on a ggplotly object. In the following example I want to highlight the hovered bar in black the clicked bar in blue When using 2 highlight functions, only the last one is used and it obviously overwrites the previous one. So how can I define different behaviour for click and hover-events? Data: dnew <- {structure(list(time_stamp = structure(c(1514761200, 1514847600, 1514934000, 1515020400, 1515106800, 1515193200, 1515279600, 1515366000, 1515452400

Combined geom_bar and geom_point legend in ggplotly

点点圈 提交于 2021-01-28 09:21:46
问题 I am trying to get a combined bar + point chart with a legend for both bars different Indicators) and points (a change in the Indicator). I tried to follow along with ggplot2 legend for plot combining geom_bar and geom_point and introduced a shape into my geom_point (without doing that I could not get a legend for points). library(ggplot2) library(dplyr) library(ggthemes) library(plotly) set.seed(369) obs <- 6 values1 <- c(round(100 + rnorm(obs) * 10, 2)) values2 <- c(round(100 + rnorm(obs) *

geom_line not plotting when setting tooltip argument with ggplotly

让人想犯罪 __ 提交于 2021-01-28 05:30:36
问题 I'm trying to plot with ggplot and it was working perfectly fine but when I add in tooltip modifiers it breaks the ggplot. Here's the code for ggplot: ggplot() + # mean in blue, must have label in both geom_point and geom_line to show up?? geom_point(data = sumsd, aes(x = Year, y = Mean, text = paste("Income Required Mean:", round(meanir, 2))), color = "blue") + geom_line(data = sumsd, aes(x = Year, y = Mean, text = paste("Income Required Mean:", round(meanir, 2))), color = "blue") + # median

Ggplotly with tooltip has problems using geom_rect()

有些话、适合烂在心里 提交于 2021-01-27 20:05:23
问题 I am trying to plot some data in a ggplotly plot. The x-axis contains dates. Ggplotly doesn't work well with dates as when I hover over a point, the date is displayed as a number. I solved this by setting a tooltip like below. Some sample data: x <- data.frame(Date = as.Date(seq(Sys.Date(), Sys.Date() + 29, by = "days")), Amount = seq(-10000, 19000, by = 1000), stringsAsFactors = FALSE) The plot: ggplotly(ggplot(x, aes(x = Date, y = Amount, group = 1, text = paste("Date: ", Date, "<br>Amount:

R renderPlotly has white background

与世无争的帅哥 提交于 2020-12-15 04:38:58
问题 I am new in R . This moment I am going to draw some visualization using ggplot2 (Everything is done). My visualization has an image as a background. When I am going to use renderPlotly on the server and plotlyOutput in UI, but background is always white. If I use renderPlot on the server and plotOutput in UI, it works fine. I really need to use renderPlotly . Also, I tried to use ggplotly . ggplotly(ggplot2_object) but background is still white. Any ideas ? Thanks ! 来源: https://stackoverflow

R renderPlotly has white background

試著忘記壹切 提交于 2020-12-15 04:38:50
问题 I am new in R . This moment I am going to draw some visualization using ggplot2 (Everything is done). My visualization has an image as a background. When I am going to use renderPlotly on the server and plotlyOutput in UI, but background is always white. If I use renderPlot on the server and plotOutput in UI, it works fine. I really need to use renderPlotly . Also, I tried to use ggplotly . ggplotly(ggplot2_object) but background is still white. Any ideas ? Thanks ! 来源: https://stackoverflow