plotly

Getting <script> and <div> tags from Plotly using Python

笑着哭i 提交于 2019-11-30 09:38:56
I was wondering if anyone knew a good way (preferably a built in method, but I'm open to writing my own of course) to get the <script> and <div> tags from the HTML output of the Plotly offline client. I'm already familiar with bokeh and really enjoy using it for 2D visualization, but would really like to integrate Plotly as well for its 3D visualization capabilities. Let me know if you need any extra details about the project. If you call: plotly.offline.plot(data, filename='file.html') It creates a file named file.html and opens it up in your web browser. However, if you do: plotly.offline

Python — Setting Background color to transparent in Plotly plots

心不动则不痛 提交于 2019-11-30 08:25:38
My python code creates a plotly Bar plot but the background is white in color i want to change it into transparent color is that doable My Code: import plotly.plotly as py from plotly.graph_objs import * py.sign_in('username', 'api_key') data = Data([ Bar( x=['Sivaranjani S', 'Vijayalakshmi C', 'Rajeshwari S', 'Shanthi Priscilla', 'Pandiyaraj G', 'Kamatchi S', 'MohanaPriya', 'Madhumitha G', 'Franklin Alphones Raj J', 'Akfaris Almaas', 'Biswajit Champati', 'Priya R', 'Rekha Rajasekaran', 'Sarath Kumar B', 'Jegan L', 'Karthick A', 'Mahalakshmi S', 'Ragunathan V', 'Anu S', 'Ramkumar KS', 'Uthra R

plotly: Updating data with dropdown selection

一曲冷凌霜 提交于 2019-11-30 07:40:58
问题 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

python save plotly plot to local file and insert into html

雨燕双飞 提交于 2019-11-30 06:09:24
问题 I am using python and plotly to product interactive html report. This post gives a nice framework. If I produce the plot(via plotly) online, and insert the url into the html file, it works but refreshing the charts takes a long time. I wonder if I could produce the chart offline and have it embedded in the html report, so that loading speed is not a problem. I find plot offline would generate a html for the chart, but I don't know how to embed it in another html. Anyone could help? 回答1:

Flex items not shrinking when window gets smaller [duplicate]

北城以北 提交于 2019-11-30 04:45:08
This question already has an answer here: Why don't flex items shrink past content size? 1 answer I'm trying to fit two plotly plots next to each other inside a CSS flexbox. I want them to resize when the window is resized. It works as expected when the window grows, but the plots don't shrink when the window gets smaller. var trace1 = {}; var trace2 = {}; var plotdiv1 = document.getElementById("plotdiv1"); var plotdiv2 = document.getElementById("plotdiv2"); Plotly.newPlot(plotdiv1, [trace1]); Plotly.newPlot(plotdiv2, [trace2]); window.addEventListener("resize", function() { Plotly.Plots

Cufflinks for plotly: setting cufflinks config options launches

▼魔方 西西 提交于 2019-11-30 04:22:01
问题 I'm trying to use cufflinks locally to generate plotly graphs from a pandas Dataframe However, when I try and configure cufflinks in a python console, it then goes into ipython mode: >>> import cufflinks as cf >>> cf.set_config_file(offline=True) In : Subsequently, when I try and generate a plot, nothing appears: In : df.iplot(kind='bar', barmode='stack', filename='cufflinks/test') In : Can cufflinks be used offline without a plotly account? 回答1: I think the issue is setting the filename

size legend for plotly bubble map/chart

[亡魂溺海] 提交于 2019-11-30 03:26:18
问题 Here is a plotly "bubble" map (i.e. a map with markers on it, whose size is mapped to a variable). However, the legend only shows the color categories, but does not show how size relates to value. library(plotly) DF = data.frame( Group = c("A", "B", "A", "B", "A", "C", "C"), Value = c(100, 80, 90, 150, 120, 60, 110), lat = c( 40, 32, 36, 44, 31, 39, 37), long = c(-90, -100, -120, -110, -90, -80,-105)) plot_geo(DF, locationmode = 'USA-states') %>% add_markers(y=~lat, x=~long, color=~Group,

Use bsModal in the shinyBS package with plotly R plotly_click to generate new plot in pop up

淺唱寂寞╮ 提交于 2019-11-29 23:31:46
问题 Here is my code for a basic shiny app using plotly_click event to optionally show another plot. I would like that side box plot to render in a modal pop up instead of on the side within the page. library(shiny) library(plotly) df1 <- data.frame(x = 1:10, y = 1:10) df2 <- data.frame(x = c(rep('a', 10), rep('b', 10)), y = c(rnorm(10), rnorm(10, 3, 1))) ui <- fluidPage( column(6, plotlyOutput('scatter')), column(6, plotlyOutput('box')) ) server <- function(input, output) { output$scatter <-

Plotly as png in knitr/rmarkdown

谁说我不能喝 提交于 2019-11-29 23:17:12
The following Rmarkdown renders the plotly 3D graph in HTML, but not in PDF. Testing plotly ```{r} library(plotly) p <- plot_ly(data=iris, x=~Sepal.Length, y=~Sepal.Width, z=~Petal.Length, color=~Species, symbols=c(0,1), type="scatter3d", mode="markers") p ``` A snapshot of the graph appears as follows: According to the plotly help page : If you are using rmarkdown with HTML output, printing a plotly object in a code chunk will result in an interactive HTML graph. When using rmarkdown with non-HTML output, printing a plotly object will result in a png screenshot of the graph. Is there a way to

Place a chart in plotly popup

眉间皱痕 提交于 2019-11-29 20:33:07
问题 I'm using plotly for R, although I'm open to using the Python version, as well. When I hover over a datapoint, is there a way to make the popup contain another chart? Ideally the chart would be created from the data, although I can use a static image as a fallback. I'm unsure where to start on this, and apologize in advance for not having an MWE. 回答1: Solution 1: Stick to R Thanks to @MLavoie. The following example use pure R to create two plot, the "mainplot" and the "hover" which reacts to