plotly

Import Plotly.js in Angular

五迷三道 提交于 2019-12-05 15:25:11
I followed the instructions from this SO answer to integrate plotly in the application. Unfortunately I experience typescript errors, when trying out the standard examples of plotly.js. The argument types of Plotly.newPlot(...) seem to be not correct. Here is my component: import {Component, OnInit} from '@angular/core'; import * as Plotly from 'plotly.js'; import {Config, Data, Layout} from 'plotly.js'; @Component({ selector: 'app-tabs', templateUrl: './tabs.component.html', styleUrls: ['./tabs.component.css'] }) export class TabsComponent implements OnInit { constructor() { } ngOnInit() {

Major and minor tickmarks with plotly

断了今生、忘了曾经 提交于 2019-12-05 15:18:34
I would like to generate a figure in plotly like the following figure generated with the base R graphics: The R code for the figure above is the following: x = c(1,2,3,4,5) y = c(0.1, 1, 10, 100, 1000) axseq = y plot(x, log10(y), yaxt="n") axis(2, at=log10(axseq), labels=as.character(axseq)) for (i in 1:5){ bb = 1:10; a = (bb*10^(i-2)); axis(2, at=log10(a), tcl=-0.25, labels=F) } My plotly code for the same figure so far is the following: p = plot_ly(x=x, y=log10(y), mode="markers") %>% layout(yaxis = list(tickmode="array", tickvals=log10(axseq), ticktext=as.character(axseq), zeroline=F,

Display python plotly graph in RMarkdown html document

徘徊边缘 提交于 2019-12-05 14:52:24
Why plotly package of python can not display figure in RMarkdown but matplotlib can? For example: ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE) ``` ```{r} library(plotly) subplot( plot_ly(mpg, x = ~cty, y = ~hwy, name = 'default'), plot_ly(mpg, x = ~cty, y = ~hwy) %>% add_markers(alpha = 0.2, name = 'alpha'), plot_ly(mpg, x = ~cty, y = ~hwy) %>% add_markers(symbols = I(1), name = 'hollow') ) ``` ```{python} import plotly import plotly.plotly as py import plotly.graph_objs as go import numpy as np plotly.tools.set_credentials_file(username='xxx

Is it possible to use R Plotly library in R Script Visual of Power BI?

冷暖自知 提交于 2019-12-05 14:08:30
Has anyone tried using Plotly or Highchart in R Script Visual of Power BI, when I try this in R script editor and Run: library(ggplot2) library(plotly) x <- 1:5 y <- c(1, 3, 2, 3, 1) plot_ly(x = dataset$period, y = dataset$mean, name = "spline", line = list(shape = "spline")) Error Message: No image was created. The R code did not result in creation of any visuals. Make sure your R script results in a plot to the R default device. But runs perfectly on my R desktop. Any thought? For newer versions of PowerBI, it's also possible to produce Plotly charts using, R and ggplot as custom PowerBI

Scaling plotly figures in knitr Latex document

喜你入骨 提交于 2019-12-05 13:58:16
I'm trying to include a plotly chart into a Latex document with knitr. Since knitr includes the webshot package this works well. But if I want to resize my figure for the latex output, the figure environment gets bigger but the plotly chart is not scalled to the manually set figure width and height. Specifing the webshot options like recommend here , did not work neither. Scaling a ggplot chart works well, but how can I get the same results for the plotly chart? \documentclass{article} \usepackage{cleveref} <<setup, echo=FALSE, message = FALSE, warning = FALSE>>= library(ggplot2) library

Removing the borders in geom_boxplot in ggplot2

让人想犯罪 __ 提交于 2019-12-05 13:24:55
This should seem relatively straightforward but I can't find an argument which would allow me to do this and I've searched Google and Stack for an answer. Sample code: library(ggplot2) library(plotly) dat <- data.frame(cond = factor(rep(c("A","B"), each=200)), rating = c(rnorm(200),rnorm(200, mean=.8))) p <- ggplot(dat, aes(x=cond, y=rating, fill=cond)) + geom_boxplot() p <- ggplotly(p) This outputs the first graph, I would want something like the second. I tried including colour=cond but that gets rid of the median. Two possible hacks for consideration, using the same dataset as Marco Sandri

Plotly R order legend entries

女生的网名这么多〃 提交于 2019-12-05 12:56:46
Is it possible to order the legend entries in R? If I e.g. specify a pie chart like this: plot_ly(df, labels = Product, values = Patients, type = "pie", marker = list(colors = Color), textfont=list(color = "white")) %>% layout(legend = list(x = 1, y = 0.5)) The legend gets sorted by which Product has the highest number of Patients. I would like the legend to be sorted in alphabetical order by Product. Is this possible? Yes, it's possible. Chart options are here: https://plot.ly/r/reference/#pie . An example: library(plotly) library(dplyr) # Dummy data df <- data.frame(Product = c('Kramer',

Plotly gives an empty field as output in jupyter lab

試著忘記壹切 提交于 2019-12-05 12:44:18
I'm using plotly at jupyter lab, but I'm getting a blanked output. I'm having exactly the same problem described here: plotly.offline.iplot gives a large blank field as its output - why? And I tried what they suggested in the answers, but it didn't work. Here is the code I'm using: import pandas as pd import numpy as np %matplotlib inline from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot init_notebook_mode(connected=True) cf.go_offline() df = pd.DataFrame(np.random.randn(100,4), columns='A B C D'.split()) df2 = pd.DataFrame({'category':['A','B','C'], 'values':[32,43

R: Set Plotly hovermode to “compare data on hover”

落爺英雄遲暮 提交于 2019-12-05 10:44:07
I am trying to create a stacked area chart in R using the Plotly package as part of a Shiny app and would like to compare the data on hover. However, I am hiding the mode bar for design reasons, so I need to declare this option in my code as currently the hover is only shown for the closest data point to the cursor. However, the Plotly for R reference only gives the options "x" (tooltip on the x-axis), "y" (tooltip on the y axis), "closest" (shows the tooltip for the closest data point to the cursor) and FALSE (disables the tooltip). Is there a way to do what I would like? Note that this

R plotly stacked bar chart with over 100 categories

淺唱寂寞╮ 提交于 2019-12-05 10:23:10
I have a dataset that contains over 100 categories. If I am going to plot it, I have to write over 100 lines code for it. Here is the example from plotly official website: library(plotly) Animals <- c("giraffes", "orangutans", "monkeys") SF_Zoo <- c(20, 14, 23) LA_Zoo <- c(12, 18, 29) data <- data.frame(Animals, SF_Zoo, LA_Zoo) p <- plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>% add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>% layout(yaxis = list(title = 'Count'), barmode = 'stack') As you can see, if I have over 100 zoos that are going to be plotted, I need to write