plotly

plotly + ggplot2: Some tooltips missing in stacked barplot

非 Y 不嫁゛ 提交于 2019-12-02 03:33:08
问题 Given for example library(ggplot2) library(plotly) df <- data.frame(V1=gl(6,20), V2=gl(40,3)) p <- ggplot(df, aes(x=V1, fill=V2)) + geom_bar(color="white") ggplotly(p) some bar segments show no tooltip/hover information, whereas the legend displays the huge number of factor levels nicely (=scroll bar). How can I fix this? I'm using packageVersion("ggplot2") # [1] ‘2.2.0’ packageVersion("plotly") # [1] ‘4.5.6’ Edit/FYI: Crossposted to GitHub. 回答1: adding some code. We can fix it: library

Arranging bars of a bar plot with “null” in Descending order in R

a 夏天 提交于 2019-12-02 02:57:21
I want to create a bar plot with Descending bars, In the plot below, due to NA being present at 2nd spot in "a1" vector, it is pushed at the last when the plot is created. However, I want the NA bar to be present at the 2nd spot only, kindly help me here as I want to achieve this without modifying my data. library(ggplot2) library(plotly) a1 = c("A",NA,"B","C","D","F") b1 = c(165,154,134,110,94,78) a12 = data.frame(a1,b1,stringsAsFactors = FALSE) pp1 <<- ggplot(a12 , aes(x = reorder(a1,-b1), y = b1,text=paste("User: <br>",a1, "<br> Days: <br>", round(b1)))) + geom_bar(stat = "identity", fill =

Multiple plotly pie charts in one row

拜拜、爱过 提交于 2019-12-02 01:58:32
I am trying to arrange two pie charts in a single row using the subplot function from the plotly package but the resultant plot is not what I expect. I was able to do the same for line charts, etc but I am facing trouble plotting two pie charts in a single row. Following is the code that I have. ds_r <- data.frame(labels = c("Baseline", "DTC", "Detailing", "Flex"), values = c(63.5, 8.5, 20.6, 7.4)) ds_l <- data.frame(labels = c("Baseline"), values = c(100)) plot_right <- plot_ly(ds_r, labels = labels, values = values, type = "pie") %>% layout(title = "Sales - Decomposed") plot_left <- plot_ly

plotly graph doesn't show up

泪湿孤枕 提交于 2019-12-02 01:55:32
问题 I'm using shiny and I can't get a plotly graph to appear. It was appearing before, I don't know what changed. MRE: global.r (or put this into server.r) library(shinydashboard) library(plotly) server.r shinyServer(function(input, output, session) { output$plotlyGraph <- renderPlotly({ input$regraph print("graphing...") return(plot_ly(list(blank = 0))) }) }) ui.r dashboardPage( dashboardHeader(title = "The Title"), dashboardSidebar( actionButton("regraph", "graph again") ), dashboardBody( box

Plotly and ggplot with facet_grid in R: How to to get yaxis labels to use ticktext value instead of range value?

老子叫甜甜 提交于 2019-12-02 01:48:50
问题 I would like to use ggplot2 facets with plotly but am running into issues with the y-axis labels showing the yaxis range values instead of the ticktext. Is there something I can alter in the plotly object (using plotly_build) to get it to render correctly. I'd really like to leverage the hover features of plotly in a shiny app on ggplots. I have found a few other questions that are related to facets in plotly but most appear to redirect users to use plotly subplots instead of ggplot. In my

How can I combine a line and scatter on same plotly chart?

狂风中的少年 提交于 2019-12-02 01:21:45
The two separate charts created from data.frame work correctly when created using the R plotly package. However, I am not sure how to combine them into one (presumably with the add_trace function) df <- data.frame(season=c("2000","2000","2001","2001"), game=c(1,2,1,2),value=c(1:4)) plot_ly(df, x = game, y = value, mode = "markers", color = season) plot_ly(subset(df,season=="2001"), x = game, y = value, mode = "line") Thanks in advance There are two main ways you can do this with plotly, make a ggplot and convert to a plotly object as @MLavoie suggests OR as you suspected by using add_trace on

Plotly background images

北慕城南 提交于 2019-12-02 01:13:56
I'm trying to get a background image on my graph using plotly. I can't seem to get ANY image to display without using one of the images.plot.ly links. I tried web URLs and local images in the same folder as the project. This is what is showing up when I used the image URL from their tutorial: https://plot.ly/python/images/ This is the only time I can get anything to show up. Any other link just produces nothing on the graph. Any tips? I have searched high and low for this. layout = dict(title = 'Crime Cluster Statistics', yaxis = dict(zeroline = False), xaxis = dict(zeroline = False), images=

Is there a way to hide Trace Names in Plotly (specifically R)?

北城余情 提交于 2019-12-02 00:07:01
I've been wracking my brain over how to get rid of the trace name with plotly and can't seem to find anything. It seems adding the trace name is a unique feature of plotly boxplots. I could just name it " " but I need the original trace name so that I can reference it when overlaying a marker. I've simplified the code as much as possible to the root issue. Is there a way to hide the trace name? housing = read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data") colnames(housing) = c("CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B",

plotly + ggplot2: Some tooltips missing in stacked barplot

自古美人都是妖i 提交于 2019-12-01 23:34:46
Given for example library(ggplot2) library(plotly) df <- data.frame(V1=gl(6,20), V2=gl(40,3)) p <- ggplot(df, aes(x=V1, fill=V2)) + geom_bar(color="white") ggplotly(p) some bar segments show no tooltip/hover information, whereas the legend displays the huge number of factor levels nicely (=scroll bar). How can I fix this? I'm using packageVersion("ggplot2") # [1] ‘2.2.0’ packageVersion("plotly") # [1] ‘4.5.6’ Edit/FYI: Crossposted to GitHub . adding some code. We can fix it: library(ggplot2) library(plotly) df <- data.frame(V1=gl(6,20), V2=gl(40,3)) p <- ggplot(df, aes(x=V1, fill=V2)) + geom

Stacked Area Chart in Plot.ly and R

百般思念 提交于 2019-12-01 23:33:00
问题 Plot.ly has a tutorial on this for Python: # Add original data x=['Winter', 'Spring', 'Summer', 'Fall'] y0_org=[40, 80, 30, 10] y1_org=[20, 10, 10, 10] y2_org=[40, 10, 60, 80] # Add data to create cumulative stacked values y0_stck=y0_org y1_stck=[y0+y1 for y0, y1 in zip(y0_org, y1_org)] y2_stck=[y0+y1+y2 for y0, y1, y2 in zip(y0_org, y1_org, y2_org)] R doesn't seem to have any similar tutorial. I tried to play with the filled area plot tutorial for R, but failed to build a stacked plot.