plotly

3D Biplot in plotly - R

拟墨画扇 提交于 2019-12-11 06:09:15
问题 I want to build a 3D PCA bi-plot using plotly package because the graph is nice and interactive in html format (something that I need). My difficulty is to add the loading. I want the loading to be presented as straight lines from the point (0,0,0) (i.e. the equivalent to 2D biplots) So all in all I don't know how to add straight lines starting from the centre of the 3D graph. I have calculated the scores and loading using the PCA function; pca1 <- PCA (dat1, graph = F) for scores: ind1 <-

How to get R plotly to use different colors for different line segments

Deadly 提交于 2019-12-11 05:03:12
问题 I can get the following to work if g is a factor variable but I would like colors treated continuously. When I run the following, the color is ignored - line segments are all blue. require(plotly) x <- rep(c(1, 1, NA, 2, 2, NA, 3, 3, NA), 2) y <- c(1, 2, NA, 2, 3, NA, 3, 4, NA, 11, 12, NA, 12, 13, NA, 13, 14, NA) g <- c(rep(1, 9), rep(2, 9)) plot_ly(x=x, y=y, type='lines', color=g) There is a solution using ggplot2 and plotly::ggplotly but I'd rather find an all- plotly solution: g <- ggplot

Shiny - align plots axis

北城以北 提交于 2019-12-11 04:44:23
问题 I have a shiny app that have 2 bar charts and one heat chart, they have the same x axis (year), I want the years to be aligned in all the plots, but I don't know how to do it. below is my UI code: ui = fluidPage( titlePanel("Global Terrorism, is it getting worse?"), tabsetPanel( tabPanel("Plot", fluid = TRUE, sidebarLayout( sidebarPanel(radioButtons( inputId="radio", label="Variable Selection Type:", choices=list( "All Countries", "Select a Country" ), selected="All Countries")

Adding a polygon to a scatter plotly

╄→гoц情女王★ 提交于 2019-12-11 04:29:25
问题 I have 5 clusters of x,y data I'm plotting using R 's plotly . Here are the data: set.seed(1) df <- do.call(rbind,lapply(seq(1,20,4),function(i) data.frame(x=rnorm(50,mean=i,sd=1),y=rnorm(50,mean=i,sd=1),cluster=i))) Here's the plot: library(plotly) clusters.plot <- plot_ly(marker=list(size=10),type='scatter',mode="markers",x=~df$x,y=~df$y,color=~df$cluster,data=df) %>% hide_colorbar() %>% layout(xaxis=list(title="X",zeroline=F),yaxis=list(title="Y",zeroline=F)) clusters.plot Now I'm creating

Add shaded rectangle with select Box corners in Plotly R

北慕城南 提交于 2019-12-11 04:28:44
问题 I am trying to create an application where if a user employs the Box Select tool in Plotly, then a filled rectangle will appear alongside the Box Select. To accomplish this, I am trying to call Plotly.addTrace() to create a rectangle object (type: rect) that has the corners of the box the user selected. I am able to obtain the coordinates of the corners of the box the user selected (in the code they are called xMin, xMax, yMin, and yMax). However, I then try to create a variable called

Plotly assigning colors based on label

本小妞迷上赌 提交于 2019-12-11 04:26:30
问题 I'm sure there's a really easy way to do this but I can't for the life of me figure it out. I'm doing a scatter graph in Plot_ly. Each point that I'm plotting has been assigned a label e.g. Pass, High, Low, Sigma high etc... My problem is that I can't seem to fix what color plot_ly assigns to each label. I want Pass to always be White, High to always be Green and so on, but it seems to randomly assign colors each time. Here is the code I'm using to plot library("plotly") p <- plot_ly(PT, type

Translate a dataframe into a table using R plotly?

点点圈 提交于 2019-12-11 04:26:13
问题 I am having a hard time understanding the workings of plotly tables in R. I am not an experienced programmer, thus my question may look naive. Please consider the following dataframe: data<-data.frame( SeqName=c("1", "2", "3", "4", "5", "6"), Length=c("440", "511", "1087", "686", "867", "632"), Cys=c("3", "2", "2", "2", "2", "4"), NT=c("[NA]", "[B]", "[B]", "[B]", "[B]", "[B]"), NR=c("[NA]", "[B][M]", "[B]", "[B][M]", "[B][M]", "[NA]"), RefSeq=c("[NA]", "[B][M]", "[B]", "[B][M]", "[B][M]", "

Format tooltip in plotly for long text labels

天大地大妈咪最大 提交于 2019-12-11 04:24:18
问题 Consider the simple example below. Is there a way to format the plotly tooltip such that the long text labels are visible in a box, rather than this absurd rectangle that cuts off values? library(ggplot2); library(plotly) df <- data.frame(x = 1:10, y = 1:10, z = rep("the longggggggggggggggggggggggggggggestttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt

How to make a multiple trace plot as a reusable code?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 03:35:48
问题 I somehow tried to make the reusable code of plots for eg a bar_graph as: def bar(x,y,text,marker,orientation,name): barchart=[go.Bar(x=x,y=y,text=text,marker=marker,orientation=orientation,name=name)] ........ In a similar way how can I make a reusable code for multiple traces ? for this below code, fig = go.Figure() # Add Traces fig.add_trace( go.Scatter(x=list(df.index), y=list(df.High), name="High", line=dict(color="#33CFA5"))) fig.add_trace( go.Scatter(x=list(df.index), y=[df.High.mean()

How do you increase the space between the axis labels and axis titles in R using functions ggplot() and plot_ly?

。_饼干妹妹 提交于 2019-12-11 03:29:44
问题 It appears that whenever I create graphs in R using the package plotly , the axis titles always cover the axis labels. I have 2 graphs now where this occurs. What code should I use to increase the space between the axis titles and labels using plot_ly() and ggplot() ? And how do I ensure that the legend is visible in Plot 1 and not cut off? Previous StackOverflow questions give different ways to structure code but they just dont seem to work for my code. Plot 1: plot <- ggplot(dat, aes(x