plotly

Multiple line chart using plotly r

拥有回忆 提交于 2020-01-15 05:45:10
问题 I have a data frame which I am trying to plot using plotly as multiple line chart.Below is how the dataframe looks like: Month_considered pct.x pct.y pct <fct> <dbl> <dbl> <dbl> 1 Apr-17 79.0 18.4 2.61 2 May-17 78.9 18.1 2.99 3 Jun-17 77.9 18.7 3.42 4 Jul-17 77.6 18.5 3.84 5 Aug-17 78.0 18.3 3.70 6 Sep-17 78.0 18.9 3.16 7 Oct-17 77.6 18.9 3.49 8 Nov-17 77.6 18.4 4.01 9 Dec-17 78.5 18.0 3.46 10 Jan-18 79.3 18.4 2.31 11 2/1/18 78.9 19.6 1.48 When I iterate through to plot multiple lines below

Plotly deactivate x axis sorting

安稳与你 提交于 2020-01-15 05:23:08
问题 I want to plot a bar chart. On the x-axis are IDs of consultants. They range between 1000 and 2000. Each consultant has a specific number of customers (y-axis). Now I want to plot a bar chart in plotly. But plotly orders the consultant IDs ascending and interprets them as integer, but they are not. They shall be ordered like the list I give plotly. By the way in matplotlib the order is right. trace1 = go.Bar( x=consultants, y=info[0,:] ) trace2 = go.Bar( x=consultants, y=info[1,:], ) trace3 =

plotly: how to make a standalone plot in a window?

五迷三道 提交于 2020-01-15 02:38:11
问题 Is there any way to use plotly just like matplotlib, that is, making the plot appear in a pop up window? Eg, is there an simple equivalent of plt.plot([1,2,3], [2, 3, 2.5]) plt.show() I've tried various functions, but all of them seem to either create an html file or an image file. 回答1: Show in system image viewer You can open the image that is created by plotly in your default system image viewer, which is kind of a standalone window. import numpy as np import plotly.graph_objs as go fig =

Can you remove the hover-coordinate-lines in Plotly Python Scatter3d

半腔热情 提交于 2020-01-14 12:56:26
问题 When using Plotly Scatter3D , the default mouse hover-over effect displays a kind of coordinate crosshairs. Is there a way to remove this effect and just show the tooltip? 回答1: The hover effect causing the lines to show up on the axis are called spikes in Plotly. You can disable them via layout = {'scene': {'xaxis': {'showspikes': False}}} . Interactive Javascript example: Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/3d-scatter.csv', function(err, rows) { function

Plotly R with ggplot2: Use coord_polar in a geom_bar using plotly

ぐ巨炮叔叔 提交于 2020-01-14 05:26:09
问题 Is there a simple way of using coord_polar() when doing a barplot in ggplot2 using plotly? Example without using polar coordinates - It works One could also add +coord_flip() and this would still work. library(ggplot2) library(plotly) # Create fake data df <- data.frame( genre=c("Pop", "HipHop", "Latin", "Pop", "Pop", "HipHop"), artist=c("ArianaGrande", "ChrisBrown", "DaddyYankee", "EdSheeran", "LewisCapaldi", "ShawnMendes") ) # Create a ggplot bar plot in polar coordinates p <- ggplot(data

Add regression plane in R using Plotly

对着背影说爱祢 提交于 2020-01-14 04:13:21
问题 I recently tried to plot a regression pane in RStudio using the plotly library and read this post: Add Regression Plane to 3d Scatter Plot in Plotly I followed the exact same procedure and ended up with a regression plane, which is obviously not correct: EDIT: I followed the proposal in the first answer and my result looks like this: Here is my code, I commented every step: sm is the data.frame I used library(reshape2); sm <- read.delim("Supermodel.dat", header = TRUE); x1 <- sm$age x2 <- sm

Data Availability Chart in Python

徘徊边缘 提交于 2020-01-14 03:39:06
问题 I am wondering if Python has something to plot the data availability of time series with multiple variables. An example is shown below taken from Visavail.js - A Time Data Availability Chart. 回答1: Here's a suggestion using plotly in a Jupyter Notebook: Code: import random import pandas as pd import plotly.express as px from random import choices # random data with a somewhat higher # probability of 1 than 0 to mimic OPs data random.seed(1) vals=[0,1] prob=[0.4, 0.6] choices(vals, prob) data=[

Interactive Choropleth in R of Sweden

十年热恋 提交于 2020-01-14 03:11:08
问题 I'm trying to develop an interactive choropleth in a Shiny application in R. I've tried with plotly, gVis and rCharts, but still without any luck. I need to visualise it for Sweden right now, but I probably need it for other countries as well later on. This is what I have so far for gvisGeoMap: polygons <- readOGR("/ggshape", layer="SWE_adm1") polygons <- fortify(polygons, region="ID_1") data.poly <- as.data.frame(polygons) data.poly <- data.poly[,c(1,2)] data.poly.final <- data.frame

3D interactive surface plot with spatial data

给你一囗甜甜゛ 提交于 2020-01-14 02:33:07
问题 I would like to create an interactive 3D surface plot of depths in a lake, ideally using the plotly or rgl libraries. I have extracted my data from a SpatialLinesDataFrame of contour lines in Gauss-Krueger/EPSG:31468 CRS, i.e. metric units. Now each contour line produces a set of coordinates with the same depth value. The resulting data frame is rather large, but looks something like this: set.seed(41) xx <- rnorm(100,4448929,100) yy <- rnorm(100,5308097,100) zz <- c(rep(-10,10),rep(-20,10)

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

痞子三分冷 提交于 2020-01-13 19:48:08
问题 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