plotly

Python - plotly assigning scatterplot colors by label

时光怂恿深爱的人放手 提交于 2019-12-06 06:14:44
I'm trying to replicate one of the basic examples in Plotly R https://plot.ly/r/line-and-scatter/#qualitative-colorscales into Plotly Python. But finding it impossible. The same problem is also solved in R here: Plotly assigning colors based on label ``` trace0 = go.Scatter( x = x1, y = y1, mode = 'markers', name = ytitle + ' X vs ' + Atitle, marker=dict(size=4, symbol='circle', color=colorsIdx, colorbar= go.ColorBar(title= 'colorbar'), colorscale='Viridis') ) ``` The closest I've gotten is using a colorbar, but that is suboptimal since I can't figure out how to pick colors so that they don't

Disable hover text in plotly with ggplot

ⅰ亾dé卋堺 提交于 2019-12-06 06:14:25
问题 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

How do I get data from selected points in an offline plotly python jupyter notebook?

允我心安 提交于 2019-12-06 05:54:08
问题 Example code: from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot import plotly.graph_objs as go import numpy as np N = 30 random_x = np.random.randn(N) random_y = np.random.randn(N) # Create a trace trace = go.Scatter( x = random_x, y = random_y, mode = 'markers' ) data = [trace] # Plot and embed in ipython notebook! iplot(data, filename='basic-scatter') [ ] How do I get a copy of the x,y data, or the indices from the selection? 回答1: So if you want to use javascript

Using Plotly with DT via crosstalk in Shiny

梦想的初衷 提交于 2019-12-06 05:28:32
I am writing an app to read a csv file into shiny and link a plotly scatter plot with a DT table. I pretty much followed the example from the Plotly website on DT datatable ( https://plot.ly/r/datatable/ ) with the exception that the saved data from the csv is saved as a reactive input and that I have selectinput for the x and y variables for the scatterplot. I can generate the plot and DT table after clicking on the action button and I can also update the DT to only show selected rows from brushing the scatterplot. My problem is that when I select rows in the DT, then the corresponding

Shiny plotlyOutput() not responding to height and width sizes

送分小仙女□ 提交于 2019-12-06 05:20:46
问题 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),

Plotly import error for exceptions module

荒凉一梦 提交于 2019-12-06 05:19:05
问题 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

Converting ggplot object to plotly object creates axis title that overlaps tick values

萝らか妹 提交于 2019-12-06 05:01:35
I had the same issue described in this question: R: ggplot and plotly axis margin won't change but when I implemented the solution, I got the following error: Warning: Ignoring unknown aesthetics: text We recommend that you use the dev version of ggplot2 with ggplotly() Install it with: devtools::install_github('hadley/ggplot2') Error in tmp [[2]] : subscript out of bounds This code will produce this error on my machine: library(gapminder) library(plotly) library(ggplot2) lead <- rep("Fred Smith", 30) lead <- append(lead, rep("Terry Jones", 30)) lead <- append(lead, rep("Henry Sarduci", 30))

How to draw ellipsoid with plotly

跟風遠走 提交于 2019-12-06 04:20:13
Are there any way to plot a surface like ellipsoid with plotly 3D? Currently only surfaces of the form z=f(x,y) are discussed in the docs. There is also Mesh 3D , but I found no examples for it. It seem to be possible to make a triangulation of ellipsoid manually and then use Mesh to get ellipsoid, but it looks a bit difficult for me. Are there any better way to do it? Okay, it is easier than I thought. There is alphahull option that asks plotly to calculate the corresponding triangulation automatically. from plotly.offline import iplot, init_notebook_mode from plotly.graph_objs import Mesh3d

Using ipywidgets with plotly in jupyter notebook

筅森魡賤 提交于 2019-12-06 04:09:30
I want to use the offline plotting of plotly inside a jupyter notebook and want to manipulate or redraw the plot by using widgets from ipywidgets. Unfortunately I do not manage to update the plots appropiately: from ipywidgets import widgets, HBox, Output import plotly as py from plotly.offline import iplot from IPython.display import display %matplotlib inline ip_widget = widgets.FloatSlider( value=6, min=3, max=10, step=1, description='num', continuous_update = True ) ow = Output() def response(change): with ow: iplot([{'x':list(range(int(ip_widget.value))), 'y': list(range(int(ip_widget

Plotting Ellipse3d in R Plotly with surface ellipse

為{幸葍}努か 提交于 2019-12-06 04:05:25
Similar to the question here but this didn't give me excatly what I needed and I couldn't figure it out: Plot ellipse3d in R plotly? . I want to recreate rgl's ellipse3d and surface ellipsoid in plotly. I know there there was an anwer which allowed plotting of an ellipse but as individual opaque markers, I need to get it as a surface ellipsoid that's slightly opaque so I can still see the data points in the ellipsoid. I tried to figure out how dww's comment for "add_surface" instead works but couldn't figure it out.... Can anyone help please? if (!require("rgl")) install.packages("rgl") dt <-