r-plotly

same code for function plot_ly in R gives different results in a project and in RGui: Error in Layout, unused arguments

爱⌒轻易说出口 提交于 2019-12-25 00:48:00
问题 I'm launching a simple function inside a project in RStudio for R3.4.0 for Windows 10. #' TestPlotly #' @export #' @importFrom plotly plot_ly #' @importFrom graphics layout #' @importFrom magrittr "%>%" TestPlotly=function() { plot_ly(x = 1:10, y = 1:10,type="scatter",mode="lines") %>% layout( xaxis = list(title="tr"), yaxis = list(title="ts") ) } I get: Error in layout(., xaxis = list(title = "tr"), yaxis = list(title = "ts")) : unused arguments (xaxis = list(title = "tr"), yaxis = list

Custom hover effects for each point in plotly boxplot with markers in R

跟風遠走 提交于 2019-12-24 19:28:20
问题 The following link - https://plot.ly/r/box-plots/#basic-boxplot - leads to the main tutorial that plotly offers for boxplots in R, and the specific plot type that I am interested in working with is the following: p <- plot_ly(y = ~rnorm(50), type = "box", boxpoints = "all", jitter = 0.3, pointpos = -1.8) In particular, I would like to play around with the hovertext on these plots, so that I am able to hover over each point individually. For anybody familiar with plotly, is this possible with

Temporarily exclude points in plotly graph

徘徊边缘 提交于 2019-12-24 06:07:37
问题 In the following plotly example (taken from here), is it possible to introduce a function that allows the user to click on a point to 'grey it out', so it would be excluded from the 'active' dataset, and the loess fit line would automatically adjust to the new dataset? The point(s) could then be clicked again to bring them back into the 'active' data set. Could be tricky. As the comments suggest it will likely require shiny , but I’m having trouble figuring out how. library(plotly) library

Plotly scaleY not working across subplot rows

心不动则不痛 提交于 2019-12-23 23:25:06
问题 Building up on another question (How to remove duplicate legend entries w/ plotly subplots()), I am facing a new problem. I want all plots in both rows to have the same Y-axis. However, If I turn "shareY = TRUE", the plots on the upper row share an axis, and the plots on the lower row do, but the axis differ from one another. The code is basically the one from the answer by @Joris Chau, but added "shareY = TRUE" on the last line. library(plotly) library(tidyverse) mpg %>% mutate_at("trans",

adding/removing traces in plotly per onclick event

独自空忆成欢 提交于 2019-12-23 17:15:02
问题 I'm trying to print an interactive pie chart. On a click on the plot another trace should be added. I'm using event_data for this. When the trace is added, on the next click anywhere on the page the trace shall be removed. I didn't find a solution for that. I don't know how to overwrite the onclick-event after another click. The next Problem would be to remove the before added trace. I think i could use plotlyProxy for that like in Removing traces by name using plotlyProxy (or accessing

Plotly: Parallel Coordinates Plot: Axis Styling

非 Y 不嫁゛ 提交于 2019-12-23 12:17:51
问题 I really like the parallel coordinates plot available in Plotly but I just ran into an issue I could use help with. Is it possible to have log10 based axis for some of the coordinates? As you can see in the example below performing a log10 transform allows to better distinguish the smaller values. However, by transforming the data we loose the ability to interpret the values. I would prefer to log scale the axis instead of the data but couldn't find a way to do this. I did find something

custom colors in R Plotly

泪湿孤枕 提交于 2019-12-23 08:27:40
问题 I'm currently a beginner in Plotly and have a problem I can't seem to solve. I have my plotly stacked bar chart but I don't know how to color each individual category. I am currently using R. This is my current stacked bar chart: My current code is: p = plot_ly(x, x = day, y = count, type = "bar", group = status) %>% layout(barmode = "stack", showlegend = T) I've tried using the "color = " parameter and also markers, but nothing correctly colors my graph. 回答1: You need to specify a factor for

Change color of markers of a trace in plotly with plotly proxy without changing the marker size

笑着哭i 提交于 2019-12-22 10:26:57
问题 I'm trying to use plotlyproxy to change the color of a trace , which works, but the problem is, is that it also alters the size of my markers / legendmarkers . A long time ago I found out that there is (as far as my current research shows) still no way to separately set the size of legend markers to be different than the plot marker. A disaster if you want to plot 5000 points in a scatter plot if you ask me as you end up with either tiny legends or giant plot markers. So the question is an A

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

你说的曾经没有我的故事 提交于 2019-12-20 03:14:28
问题 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 回答1: There are two main ways you can do this with plotly,

How to format data for plotly sunburst diagram

拈花ヽ惹草 提交于 2019-12-18 18:28:37
问题 I'm trying to make an sunburst diagram using Plotly via R. I'm struggling with the data model required for the hierarchy, both in terms of conceptualizing how it works, and seeing if there are any easy ways to transform a regular dataframe, with columns representing different hierarchical levels, into the format needed. I've looked at examples for plotly sunburst charts in R, e.g., here, and seen the reference page but don't totally get the model for data formatting. # Create some fake data -