r-plotly

Set marker size based on coordinate values, not pixels, in plotly R

一世执手 提交于 2019-12-18 09:38:49
问题 This post - Set marker size in plotly - unfortunately did not help with what I was looking for, and is the only post on the topic I could find. Per the plotly documentation on the size parameter for scatter plots: "size (number or array of numbers greater than or equal to 0), default: 6, Sets the marker size (in px)" the (in px) is a problem for me. I'd like to create a plot where the marker sizes are based on the coordinate values, not pixels, that way I can increase the size of a graph (by

in R, how to automatically plots based on lists?

别说谁变了你拦得住时间么 提交于 2019-12-18 07:16:10
问题 I've got a survey results for two products categories, here is the data surveyresults<-data.frame("Name"=c("Adam","John"), "Gender"=c("m","m"), "City"=c("Sydney","Melbourne"), "Product"=c("Fashion","Electronics"), "fash_pay_cash"=c(5,"NA"), "fash_pay_card"=c(5,"NA"), "elc_pay_cash"=c("NA",5), "elc_pay_card"=c("NA",6), "fash_DlvTime_morning"=c(5,"NA"), "fash_DlvTime_afternoon"=c(7,"NA"), "elc_DlvTime_morning"=c("NA",5), "elc_DlvTime_afternoon"=c("NA",8)) surveyresults and i need to plot each

Date format in hover for ggplot2 and plotly

你说的曾经没有我的故事 提交于 2019-12-17 22:26:37
问题 I have a question about date formats in plotly . I made a time series plot in ggplot2 that I'm trying to visualize with plotly but a format issue for date-time appears on the hover (see image). I would like the date format to be YYMMD-hh:mm . How could I get this format? Relevant R code on my script: library(lubridate) datosO3.melt <- melt(datosO3.plot, id.vars="fecha", value.name="value") ozono.plot <- ggplot() + geom_line(data=datosO3.melt, aes(x=fecha, y=value, colour=variable)) ggplotly

R plotly: how to observe whether a trace is hidden or shown through legend clicks with multiple plots

最后都变了- 提交于 2019-12-17 16:55:26
问题 I am trying to figure out which traces the user hides from a scatter plot by means of deselecting them in the interactive legend of plotly. I have read this SO post, and the similar questions linked in the comments below and this brought me closer to the solution The current solution is only doing partially what I need. Two things I am looking for to improve it is: - how to see which plot's legend is clicked (looking at source 'id' ?) - I can now see that a legend entry is clicked, but I need

How to choose variable to display in tooltip when using ggplotly?

谁说我不能喝 提交于 2019-12-17 08:28:40
问题 I have a simple data frame: seq <- 1:10 name <- c(paste0("company",1:10)) value <- c(250,125,50,40,40,30,20,20,10,10) d <- data.frame(seq,name,value) And I want to plot it this way: require(ggplot2) ggplot(data = d,aes(x=seq,y=value))+geom_line() + geom_point() Now I want to use plotly, mostly to be able, when mousing over a point, to get other information than the value, such as the company name. I try this : require(plotly) ggplotly() which get me a tooltip, but with only seq and value. I

R chart convert to html format without other files

落花浮王杯 提交于 2019-12-13 16:09:29
问题 My sample dataset: library(plotly) library(htmlwidgets) d <- data.frame( "name" = c("bily", "mary", "ken"), "fruit" = c("cherry", "apple", "apple"), "count" = c(1, 10, 30) ) gg <- ggplot(data = d, aes(x = fruit, y = count, group = name)) + geom_line(aes(color = name)) + geom_point(aes(color = name)) plotly <- ggplotly(gg) save graph: d <- # please put your directory where you want to save the graph "xxxx/graph.html" I have searched these three functions that can output the HTML format but

Embed logo on top of another embedded logo in plotly

安稳与你 提交于 2019-12-13 03:48:17
问题 I have this example dataset ( example_data ) of hockey shot locations I want to plot over an ice rink. structure(list(game_date = structure(c(17674, 17674, 17674, 17674, 17674), class = "Date"), event_team = c("WSH", "WSH", "T.B", "T.B", "T.B"), event_description = c("WSH #8 OVECHKIN(12), Slap, Off. Zone, 53 ft.Assists: #92 KUZNETSOV(13); #43 WILSON(8) Expected Goal Prob: 1.6%", "WSH ONGOAL - #92 KUZNETSOV, Wrist, Off. Zone, 13 ft. Expected Goal Prob: 50.4%", "T.B ONGOAL - #17 KILLORN,

Ordered bars on plotly

╄→尐↘猪︶ㄣ 提交于 2019-12-13 02:35:52
问题 I'm trying to make a CPU Usage graph with Plotly and R, I want the max usage (100%, the blue bar) on top, and the other one on bottom, but when I try this code plot_ly( x = cores, y = max, type = 'bar', name = 'Free') %>% add_trace( y = data, name = 'Used') %>% layout( title = "CPU Usage", font = list(family = 'Comic Sans MS'), yaxis = list(title = 'Percent'), xaxis = list(title = '', tickangle = -45), barmode = 'stack') }) It gives me the reverse, ordering the greater bar on bottom, and the

Plotly r, line style by variable

若如初见. 提交于 2019-12-12 16:32:22
问题 I am trying to make a scatter plot where the line style is specified by a factor variable, just as one does with colors, but I can't get it to work. library(plotly) df <- data.frame(x=rnorm(20),y=rnorm(20),col=c(rep(1,10),rep(2,10)),dash=c(1,2)) df <- df[order(df[,1]),] plot_ly(data=df,x=~x,y=~y,type="scatter",mode="lines",color=~as.factor(col),line=list(dash=~as.factor(dash))) 回答1: I found the answer myselfes: plot_ly(data=df,x=~x,y=~y,type="scatter",mode="lines",color=~as.factor(col)

Why does ggplotly break when ggtern is loaded?

回眸只為那壹抹淺笑 提交于 2019-12-11 19:44:59
问题 I was hoping to use plotly::ggplotly() to plot a graph produced with ggtern() with a tooltip feature. But loading the package ggtern caused ggplotly to throw the following error: Error in inherits(theme[[element]], ggplot_global$element_tree[[element]]$class) : 'what' must be a character vector What's more, this error appears for all graphs, not just those produced by ggtern. Here is an example. library(ggplot2) # This works gg.mtcars <- ggplot(mtcars, aes(hp, mpg)) + geom_point() plotly: