plotly

plotly - different colours for different surfaces

只愿长相守 提交于 2019-11-29 10:37:15
Using plotly I would like to have each surface to have different colour. library(plotly) t1 <- seq(-3, 3, 0.1); t2 <- seq(-3, 3, 0.1) p1 <- matrix(nrow = length(t1), ncol = length(t2)) p2 <- matrix(nrow = length(t1), ncol = length(t2)) p8a1 <- 1.2 p8a2 <- 1 p8d <- -1 p8b1 <- 0.7 p8b2 <- 0.6 for (i in 1:length(t2)) { for (j in 1:length(t1)) { p1[i, j] <- 1 / (1 + exp(-1.7 * (p8a1 * t1[j] + p8a2 * t2[i] + p8d))) p2[i, j] <- (1 / (1 + exp(-1.7 * p8a1 * (t1[j]- p8b1)))) * (1 / (1 + exp(-1.7 * p8a2 * (t2[j]- p8b2)))) } } df1 <- list(t1, t2, p1) df2 <- list(t1, t2, p2) names(df1) <- c("t1", "t2",

ggplotly not displaying geom_line correctly

做~自己de王妃 提交于 2019-11-29 09:56:46
I am trying to use ggplotly to add interactivity to my ggplot chart. I have tried running this in both RStudio and from the command line, with the same results. Data: library(plotly) df1 <- as.data.frame(list('x'=1:100,'y'=1:100,'lw'=abs(rnorm(100)))) b <- ggplot(data=df1, aes(x=x,y=y)) + geom_line(size=df1$lw) If I display b normally, i.e. > b , I get a correct plot However, if I then enter ggplotly() , I get the plot below: Using my real data, the results are even worse. Below is a plot() , which is correct, followed by ggplotly() Any idea how I can display this correctly? Although this is

Plotly charts in a for loop

百般思念 提交于 2019-11-29 08:42:10
I am converting ggplot2 charts using plotly and putting them in a knitr html output. Here is a working copy of the report. http://rpubs.com/kausti/NSEFO-23-Mar-2016 The first chart is plotly chart and the following ones are not. I would like them to be plotly charts but I am stuck. In the code below, plotChart function returns a ggplot2 plot. This code works! for (tick in tradeOps$ticker) { tmpDF = filter(tradeOps, ticker == tick) p = plotChart(tick = tick,Entry = tmpDF$Entry, Target = tmpDF$Target, SL= tmpDF$SL, TradeType = tmpDF$TradeType, data = wd) p = p + annotate("text", x = as.Date

Use a custom icon in plotly's pie chart in R

ぃ、小莉子 提交于 2019-11-29 08:08:27
I was wondering if there's a way to have a custom icon for plotly's pie chart instead of the usual pie division As of now I'm displaying the gender information using a pie chart which looks as below: I'm trying to make it look like the gender plot in the link below: https://app.displayr.com/Dashboard?id=c1506180-fe64-4941-8d24-9ec4a54439af#page=3e133117-f3b2-488b-bc02-1c2619cf3914 The plotly code is as under: plot_ly(genderselection, labels = ~Gender, values = ~Freq, type = 'pie') %>% layout(title = paste0("Gender Distribution of Patients from Boston"), xaxis = list(showgrid = FALSE, zeroline

How to add line breaks to plotly hover labels

£可爱£侵袭症+ 提交于 2019-11-29 06:08:47
问题 Is there a way to get plotly to display the hover text on multiple lines/get it to recognize special characters line '\n' in the text? A dummy version of what I'm looking to do is: data <- data.frame(cbind(rnorm(10, 8), rnorm(10, 2))) names(data)<-c("thing1", "thing2") data$hovertext <- paste("here's a coordinate: ", round(data$thing1,1), sep = "\n") p <- plot_ly(data, type = 'scatter', x = thing1, y = thing2, text = hovertext, hoverinfo = 'text', mode = "markers") Which of course just

Customise the infoWindow / tooltip in R --> plotly

这一生的挚爱 提交于 2019-11-29 05:12:18
I am new to plot.ly and I just drew my first scatter plot out of R the other day - its great! testplot <- ggplot(a, aes(OR_Edu, OR_Illn, color=Country, size=total)) + geom_point() py$ggplotly(testplot) https://plot.ly/~SyTpp/14/or-illn-vs-or-edu/ Now, I would like to change the tooltip or the little info window that pops up on hover over a datapoint. In this case I am not interested in the y-coordinate but instead I would like to display the country name and the population size, which I mapped to the aestectic size. Ideally I would like to know if/how I can customize the infowindow in general,

plotly: Updating data with dropdown selection

强颜欢笑 提交于 2019-11-29 05:09:40
I am not sure if this is possible, but here is what I would like to do. I would like to update the data in a plotly plot by selecting from a dropdown menu. As a simple example, let's assume I have a data frame df <- data.frame(x = runif(200), y = runif(200), z = runif(200)) from which I use df$x and df$y in a scatter plot. Two scenarios of data manipulation I would like to achieve using a dropdown: Replace df$y with df$z Plot only the first n values of df$x and df$y I looked at the following two examples, which I can easily reproduce: https://plot.ly/r/dropdowns/ However, I have no idea how to

Embed Plotly graph into a webpage with Bottle

笑着哭i 提交于 2019-11-29 03:05:08
问题 Hi i am using plotly to generate graphs using Python, Bottle. However, this returns me a url. Like: https://plot.ly/~abhishek.mitra.963/1 I want to paste the entire graph into my webpage instead of providing a link. Is this possible? My code is: import os from bottle import run, template, get, post, request from plotly import plotly py = plotly(username='user', key='key') @get('/plot') def form(): return '''<h2>Graph via Plot.ly</h2> <form method="POST" action="/plot"> Name: <input name=

How to get Plotly.js default colors list?

有些话、适合烂在心里 提交于 2019-11-29 02:59:24
问题 I am plotting a plotly bubble chart on a webpage.. I want to get the list of default colors, plotly uses to draw the bubbles. 回答1: Plotly uses the same colors as in d3 's scale.category10() function. After 10 colors the whole color scheme starts again from 0. The colors codes can be found in KDD's answer. The snippet below gives the d3 colors and takes the Plotly colors dynamically from a plot, i.e. even if the Plotly changes the color codes will be correct. var d3colors = Plotly.d3.scale

Plotly chart is not displayed in PyCharm

与世无争的帅哥 提交于 2019-11-29 02:26:28
How can I display interactive plotly graphs in Pycharm? I run the following code: import plotly.offline as py import plotly.graph_objs as go py.init_notebook_mode(connected=True) data = [go.Bar( x=['giraffes', 'orangutans', 'monkeys'], y=[20, 14, 23] )] py.iplot(data, filename="barplot") The result in PyCharm is a blank field: In Jupyter Notebook this code gives a (proper) interactive chart as the result. Update: Answers from Embed Plotly HTML in PyCharm IDE don't work for me. When I use the plot() function (instead of the iplot() ) it exports the chart into separate file and open a browser in