plotly

Shiny plotlyOutput() not responding to height and width sizes

心不动则不痛 提交于 2019-12-04 10:20:48
I am creating a Shiny app with a plotly scatterplot. I am trying to keep the scatterplot square-shaped, but want a much larger size than its default. In the simple MWE below, for instance, I am setting the width and height parameters to 1400px. However, even when I change these values (say to 800px), it does not seem to make any change in the size of the plotly scatterplot. library(plotly) library(shiny) library(ggplot2) set.seed(1) dat <- data.frame(ID = paste0("ID", 1:100), x = rnorm(100), y = rnorm(100), stringsAsFactors = FALSE) ui <- shinyUI(fluidPage( titlePanel("title panel"),

Plotly import error for exceptions module

微笑、不失礼 提交于 2019-12-04 10:10:23
I have searched all over and couldn't find the solution to this problem. I am trying to import plotly in Jupyter Notebook with following code and getting the following error respectively Code: import sys print(sys.path) sys.path.append('/usr/local/lib/python2.7/dist-packages') import plotly Error: --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-3-b41540b5e198> in <module>() 3 sys.path.append('/usr/local/lib/python2.7/dist-packages') 4 ----> 5 import plotly /usr/local/lib/python2.7/dist-packages/plotly/_

How to link plotly traces for legend and colour selection?

非 Y 不嫁゛ 提交于 2019-12-04 09:57:04
Problem I am migrating a number of ggplot / ggvis plots to plotly in a shiny application. There is an issue I've encountered regarding the linking of traces. I want to be able to show/hide traces by group on the legend, which is shared between related data frames. Minimal working example # load libraries library(dplyr) library(plotly) library(viridis) # contrived data to represent actual data points df1 <- data.frame(x = rnorm(100), y = rnorm(100), group = rep(c("G1", "G2", "G3", "G4"), 25)) # contrived data to represent theoretical relationship df2 <- data.frame(x = c(rep(-2, 4), rep(2, 4)),

Disable hover text in plotly with ggplot

假装没事ソ 提交于 2019-12-04 09:51:43
I want to partly disable hover text in plotly, limiting it to one dataframe or geom in ggplot. In the case below, I want hover only on the "cities" not the map outline. I've seen a solution in Python, but not R. And how would I control the image size to keep the map dimension right in plotly? The map demo at https://plot.ly/ggplot2/interactive-tooltip/ seems not to care! library(mapdata) library(ggplot2) library(plotly) Japan <- map_data("world2Hires", region="Japan") Longitude <- 140 Latitude <- 36.5 df <- cbind.data.frame(Longitude,Latitude) df$Name <- "Tokyo" df$Name_2 <- "Tōkyō" XX <-

Use plotly offline to generate graphs as images

和自甴很熟 提交于 2019-12-04 09:15:47
问题 I am working with plotly offline and am able to generate an html file using plotly.offline.plot({"data": data, "layout": layout}) It works great. The graph is generated correctly and the html file gets saved to my current directory. What I want, though is, using plotly offline, is to have an image (.png, .jpg, etc.) file saved instead. Am I on the right track? What do I need to do from here? 回答1: Try this import plotly.offline import plotly.graph_objs as go plotly.offline.plot({"data": [go

Using plotly in Jupyter to create animated chart in off-line mode

半腔热情 提交于 2019-12-04 08:52:30
I've been trying to get the "Filled-Area Animation in Python" example to work using plotly in offline mode in a Jupyter notebook. The example can be found here: https://plot.ly/python/filled-area-animation/ Since I'm in off-line mode, I create a local csv file containing dummy data to use as the data source, then read the csv using pandas dataframes: # Add the following line from plotly.offline import init_notebook_mode, iplot ..... # Read csv instead of using get_data_yahoo #appl = web.get_data_yahoo('AAPL', '2016-01-01', '2016-11-30') appl = pd.read_csv("C:\\test.csv") apple_data_matrix =

How to remove option bar from ggplotly plot?

◇◆丶佛笑我妖孽 提交于 2019-12-04 08:47:49
问题 I have a plot that I am rendering in shiny using plotly and ggplot2 . However, I do not want the option bar that appears on hover to appear. Is there a way to use ggplotly(p) and remove the option bar? 回答1: There is a great answer on community plotly the short version: library(plotly) set.seed(100) d <- diamonds[sample(nrow(diamonds), 1000), ] Using ggplotly : p <- ggplot(d, aes(carat, price)) + geom_point() ggplotly(p) %>% config(displayModeBar = F) If you are not using ggplotly you can do:

Y-axis autoscaling with x-range sliders in plotly

我的梦境 提交于 2019-12-04 08:30:41
Afaik, y-axis cant be made to auto scale when using x-range sliders. Y range is chosen with respect to the y values of the whole x range and does not change after zooming-in. This is especially annoying with candlestick charts in volatile periods. When you zoom-in using x-range slider, you essentially get flat candlesticks as their fluctuations only cover a very small part of the initial range. After doing some research it seems that some progress has been made here: https://github.com/plotly/plotly.js/pull/2364 . Anyone knows if there is a working solution for plotly.py ? Thanks for your time

Line hover text in Plotly

霸气de小男生 提交于 2019-12-04 07:50:44
I am plotting a graph with Plotly similar to the example on the Plotly website . Along with the hover text on the graph nodes, I want to have a hover text on the edges as well. I tried to achieve this by modifying the trace object for edges by adding a 'name' field, but this didn't work and was putting the 'name' on the nodes. trace3=Scatter( x=Xed, y=Yed, name="my_hover_text", mode='lines', line=Line(color='rgb(210,210,210)', width=1), hoverinfo='name' ) Using the 'text' field instead of the 'name' field, gives the very same result. I have also tried to have a separate trace for each edge,

Is there a way to display plots as they build in Shiny instead of waiting for all of them?

我的梦境 提交于 2019-12-04 07:46:21
I have a Shiny Dashboard with many plots, all of which take multiple seconds to build. Once the last one builds, they all display. I would like instead for each plot to display as soon as it completes. I understand R is single-threaded, but it seems as though there must be a way to "return execution to the display code" or something like that. This code demonstrates the issue: library(shiny) ui <- fluidPage( title = "Page loading test" , h1("Page loading test") , plotOutput("plot1") , plotOutput("plot2") , plotOutput("plot3") , plotOutput("plot4") ) server <- function(input, output) { output