plotly

Issue with “na” in arranging the bars in a bar plot in R and ggplot2

心不动则不痛 提交于 2019-12-12 06:38:33
问题 I am trying to create a Descending bars bar plot using ggplot2 and plotly in R. The data I am using is "a12" which is consumed by the ggplot under the line "#Final Data frame is consumed below". If you see the snap shot below, the "na" value in the column "a1" should come at second spot in the plot, however it does not follow the descending order and is pushed at the last. One way to cure this issue is to hardcode the value there, but I don't want to do that. Instead is there a way using

Custom R function around plot_ly() with fitted(lm(y~x)) using add_lines()

三世轮回 提交于 2019-12-12 05:59:15
问题 I want to write a custom function around plot_ly() in R. That way, I can make a series of scatterplots with the same formatting and style, but not duplicate code. I used this page as a guide. This code reproduces the error: library(plotly) my_plot <- function(x, y, ...) { require(broom) plot_ly(data = mtcars, y = y, x = x, showlegend = FALSE, ...) %>% add_markers(y = y) %>% add_lines(y = ~fitted(lm(y ~ x))) %>% add_ribbons(data = augment(lm(y ~ x, data = mtcars)), ymin = ~.fitted - 1.96 * .se

Don’t want to change background color at the time of dragging plotly graph

假如想象 提交于 2019-12-12 05:58:40
问题 When I dragging plotly area graph that time I want to fill area with our choice color which dragging by mouse. I don't want background color which is coming by default at the time of dragging. I referred this code When I dragging graph that time graph is coming like this: I want apposite to above image. Here, when I dragging graph by mouse that time dragged area filling by gray color and remain area of graph is filling by some light color. I don't want like this. Hope, you will understand my

Plotly.js - Reversing the horizontal bar chart in plotly

不想你离开。 提交于 2019-12-12 05:33:26
问题 I am new to plotly and am working of a bar chart example. What I want to do is have the bar chart run from right to left. Here is a link to my jsfiddle. https://jsfiddle.net/ksaluja/w0cx3sw1/1/ Currently it is going the default way from right to left. Thanks! index.html <div id="tester" style="width:600px;height:250px;"></div> scripts.js var data = [{ type: 'bar', x: [20, 14, 23], y: ['giraffes', 'orangutans', 'monkeys'], orientation: 'h' }]; Plotly.newPlot('tester', data); 回答1: You need to

Plotly in RStudio viewer

天大地大妈咪最大 提交于 2019-12-12 05:27:47
问题 I updated plotly to the newest version V2.0.3 because they say you can now have interactive plots in the viewer without hosting them on their website. When I run a plot nothing shows up in the viewer, but if I click show in new window in the viewer it opens up in a webbrowser. Any ideas why it won't show up directly in Rstudio viewer? Their demo shows that it should be able to here: https://plot.ly/r/offline/?campaign_id=open_source_dec2015&utm_source=Plotly+Community&utm_campaign=59ccfcd224

Sankey diagram using Plotly

时光总嘲笑我的痴心妄想 提交于 2019-12-12 04:35:33
问题 I wish to create a simple sankey chart using this piece of data and specifically plotly package such that, activity ABC points to Resouce "R5", "BVN" to "R1" and "IOP" to "R6". I followed the plotly post https://plot.ly/r/sankey-diagram/, but I just am not able to automate the scipt with this data. I would appreciate if you can help me do it without JSON. Data is attached below. library(plotly) library(rjson) json_file <-"https://raw.githubusercontent.com/plotly/plotly.js/master/test/image

How to add text to a plotly boxplot in r

只谈情不闲聊 提交于 2019-12-12 04:22:18
问题 I would like to mark the outlier that appears on my chart writing where it is. Is this possible with plotly? The code of my graph is here: library(plotly) set.seed(1234) plot_ly(y = rnorm(50), type = 'box') %>% add_trace(y = rnorm(50, 1)) %>% layout(title = 'Box Plot', xaxis = list(title = "cond", showgrid = F), yaxis = list(title = "rating")) 回答1: It's not clear what you tried and what's not working, but one way to identify outliers is to use boxplot.stats() and then you can use that

How to change the position of plotly figures using ggplotly

纵然是瞬间 提交于 2019-12-12 04:18:24
问题 I am trying to remove the legend title using ggplotly without success. I'm sure there is an easy fix, but I cannot find the documentation for it - and removing the legend title (or changing the positioning) using ggplot fails to work. See e.g.: # Creating the ggplot: a <- ggplot(mtcars, aes(x = interaction(cyl, carb, lex.order = T), y = mpg,fill = interaction(cyl, carb, lex.order = T))) + geom_boxplot() + theme(legend.title=element_blank()) a # No Legend Title # plotly puts back the legend

plot_ly faceting/trellis panel label and fixed height

安稳与你 提交于 2019-12-12 04:13:55
问题 Suppose I have this lovely ggplot library(plotly) library(tidyverse) mpg2=mpg%>% filter(manufacturer%>%as.factor%>%as.numeric<6)%>% group_by(manufacturer,model)%>% summarize(hwy=mean(hwy))%>% mutate(model=reorder(model,hwy)) myggplot=mpg2%>% ggplot(aes(x=model,y=hwy))+ geom_col()+ coord_flip()+ facet_grid(manufacturer~.,scales="free",space="free")+ theme(legend.position="none", axis.text.y=element_text(), axis.title.y=element_blank(), axis.text.x=element_text(size=12), strip.text.y = element

plot_geo returning a blank map in R

為{幸葍}努か 提交于 2019-12-12 03:53:22
问题 I was trying to create a Plotly map in R using plot_geo. I wasn't getting any errors, but the Viewer was returning a blank map. The Plotly mode bar was showing up, but everything else was blank. I couldn't even get the code below from the plot_geo help page to work: library(plotly) library(dplyr) map_data("world", "canada") %>% group_by(group) %>% plot_geo(x = ~long, y = ~lat) %>% add_markers(size = I(1)) Has anyone else ran into this problem? I haven't had any trouble with plotly in R in the