ggplotly

Setting ranges for a bar chart in R and displaying count of items

丶灬走出姿态 提交于 2019-12-06 15:21:41
I have created a data frame from iris dataset using the following command: new_iris = data.frame(iris$Species,iris$Sepal.Length) range(iris$Sepal.Length) The second command tells me the range of the Sepal.Length. I want to implement a bar plot using plotly or ggplot2 such that the code decides the ranges of Sepal.Length automatically and then each range contains one bar which gives the count of all the Sepal.Length values in that range. So let's say if the ranges decided are "2-4","4-6","6-8", I should get 3 bars which give me a count of all the sepal.length values between "2-4","4-6" and "6-8

R: facet_wrap does not render correctly with ggplotly in Shiny app

戏子无情 提交于 2019-12-06 14:39:58
When I do a facet_grid in ggplotly() for a Shiny App, with a large number of faceting groups, the plot is messed up. However it works correctly outside Shiny. How can I fix this? I suspect it is linked to the Y scale but I couldn't find the solution. Here's a reproducible example based on diamonds example from plotly . Comparison of Shiny vs non Shiny outputs : Comparison of facet_grid outside and within Shiny Code Outside Shiny: library(ggplot2) data(diamonds, package = "ggplot2") # new faceting group diamonds$rdmGroup <- as.factor(sample(LETTERS, dim(diamonds)[1], replace=TRUE)) # subset of

Disable hover information for a specific layer (geom) of plotly

断了今生、忘了曾经 提交于 2019-12-06 12:09:31
library(ggplot2) library(plotly) gg <- ggplot(mtcars, aes(factor(vs), drat)) + geom_violin() + geom_jitter() ggplotly(gg) In example code we use ggplot to plot violin and jitter layers. Plotly displays information for both layers (i.e. when hovered over jitter point it will display specific point information, same thing happens when hovered over the violin plot). However, I want plotly to display information only for geom_jitter . Question: How to disable hovered information for specific layer? You can set the hoverinfo to "none" for that geom : gg <- ggplot(mtcars, aes(factor(vs), drat)) +

Add plotly traces dynamically on shiny

孤街醉人 提交于 2019-12-06 07:49:28
问题 I am building an app that allows a user to dynamically add and remove traces on a plotly graph using selectInput. I have tried to play around with plotlyProxy () and plotlyProxyInvoke () from plotly package to no avail. Below is my rudimental code : library(shiny) library(shinydashboard) library(plotly) ui <- dashboardPage( dashboardHeader(), dashboardSidebar( sidebarMenu( menuItem("Search", tabName = "Tabs", icon = icon("object-ungroup")) ) ), dashboardBody( tabItem(tabName = "Tabs",

Creating Process Map Diagrams using different packages in R

て烟熏妆下的殇ゞ 提交于 2019-12-06 06:20:27
the given script simply creates a process map diagram showing the flow of events in R. This field of study is called event log mining or process mining. I wish to know any other packages or functionality in R using which I can create similar maps and also make them interactive like ggplotly. Please help me with some links if possible. Thanks and please help. library(bupaR) library(edeaR) library(eventdataR) library(processmapR) library(processmonitR) library(xesreadR) library(petrinetR) patients %>% process_map() 来源: https://stackoverflow.com/questions/46602433/creating-process-map-diagrams

Converting ggplot object to plotly object creates axis title that overlaps tick values

萝らか妹 提交于 2019-12-06 05:01:35
I had the same issue described in this question: R: ggplot and plotly axis margin won't change but when I implemented the solution, I got the following error: Warning: Ignoring unknown aesthetics: text We recommend that you use the dev version of ggplot2 with ggplotly() Install it with: devtools::install_github('hadley/ggplot2') Error in tmp [[2]] : subscript out of bounds This code will produce this error on my machine: library(gapminder) library(plotly) library(ggplot2) lead <- rep("Fred Smith", 30) lead <- append(lead, rep("Terry Jones", 30)) lead <- append(lead, rep("Henry Sarduci", 30))

How to use plotly to return the same event_data information for selected points even after modifying the data

丶灬走出姿态 提交于 2019-12-06 02:09:41
问题 I'm trying to do something seemingly simple: when the user clicks on a data point or select multiple points with lasso selection, I want to draw these points in a different colour. In order to do that, I look at what points are selected, and add a col variable to the dataframe, and I tell the ggplot to colour the points according to that column. It does work for the first selection. But whenever there are already selected points, selecting the next set of points doesn't work. I've added debug

Add custom data label in ggplotly scatterplot

♀尐吖头ヾ 提交于 2019-12-04 17:41:19
I would like to display the Species for each data point when the cursor is over the point rather than the than the x and y values. I use the iris dataset. Also I want to be able to click on a data point to make the label persistent and not get disapperaed when I choose a new spot in the plot. (if possible ). The basic is the label. The persistence issue is a plus. Here is my app: ## Note: extrafont is a bit finnicky on Windows, ## so be sure to execute the code in the order ## provided, or else ggplot won't find the font # Use this to acquire additional fonts not found in R install.packages(

Add plotly traces dynamically on shiny

北城以北 提交于 2019-12-04 14:57:47
I am building an app that allows a user to dynamically add and remove traces on a plotly graph using selectInput. I have tried to play around with plotlyProxy () and plotlyProxyInvoke () from plotly package to no avail. Below is my rudimental code : library(shiny) library(shinydashboard) library(plotly) ui <- dashboardPage( dashboardHeader(), dashboardSidebar( sidebarMenu( menuItem("Search", tabName = "Tabs", icon = icon("object-ungroup")) ) ), dashboardBody( tabItem(tabName = "Tabs", fluidRow( column(width=3, box( title="SELECT ", solidHeader=TRUE, collapsible=TRUE, width=NULL, selectInput(

Highlight all values from a group on hover

我只是一个虾纸丫 提交于 2019-12-03 05:42:02
问题 Assume data library(ggplot2) library(plotly) set.seed(357) xy <- data.frame(letters = rep(c("a", "b", "c"), times = 3), values = runif(9), groups = rep(c("group1", "group2", "group3"), each = 3)) letters values groups 1 a 0.9913409 group1 2 b 0.6245529 group1 3 c 0.5245744 group1 4 a 0.4601817 group2 5 b 0.2254525 group2 6 c 0.5898001 group2 7 a 0.1716801 group3 8 b 0.3195294 group3 9 c 0.8953055 group3 ggplotly( ggplot(xy, aes(x = letters, y = values, group = groups)) + theme_bw() + geom