plotly

Legend title in plotly

北城以北 提交于 2019-12-04 07:37:49
How do I specify title for legend in plotly ? I have a stacked bar graph that plots different durations like 0-10, 11-20. I want the legend title to say 'Duration'. The simplest way to specify a legend title is to set it via ggplot and have plotly read it from the corresponding object: library( plotly ) gg <- ggplot( mtcars, aes( x=mpg, y=wt, color=factor(vs) ) ) + geom_point() + labs( color = "MyTitle" ) ggplotly( gg ) However, the problem is that plotly converts the legend title into an annotation, which becomes disconnected from the legend in the process. In my browser, it also overlaps

How to change axis features in plotly?

拥有回忆 提交于 2019-12-04 07:26:10
I have the following bar in plotly and I want to : get the x-axis title away from the axis label so they dont overlap make the Y-axis labels bigger bring the bar values to the top of bars My code is : library(plotly) plot_ly(x = c('100-200','200-400', '400-600','600-800','800- 1000'), y = c(12261,29637,17469,11233,17043), name = "dd", type = "bar", xaxis = list(title ="tr"), yaxis = list(title = "cc") , text = c(12261,29637,17469,11233,17043),textposition = 'auto') %>% layout( xaxis = list(tickangle=15, title = " "), yaxis = list(title = " ")) Thanks for your comments :) Question 1: get the x

HTML widgets in Jupyter R Notebook

落花浮王杯 提交于 2019-12-04 06:19:27
Im unable to display HTML widgets in Jupyter Notebooks when using R (works when using python). For example none of the plotly charts work in Jupyter R notebook. Is there any solution for this? library(plotly) set.seed(100) d <- diamonds[sample(nrow(diamonds), 1000), ] plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity), mode = "markers", color = carat, size = carat) The code executes but no graph is displayed You need to make a call to embed_notebook (see the examples here ). So change your code to: library(plotly) set.seed(100) d <- diamonds[sample(nrow(diamonds), 1000), ]

Plotly animated bubble chart: no data in the plot

被刻印的时光 ゝ 提交于 2019-12-04 06:16:16
问题 I am trying to adapt the standard plotly animated bubble chart to a csv file with these columns: index,country,year,Country code,Total population (Gapminder),Life satisfaction in Cantril Ladder (World Happiness Report 2017),GDP per capita 62,Afghanistan,2008,AFG,29839994.0,3.723589897,1298.14315888 63,Afghanistan,2009,AFG,30577756.0,4.401778221,1531.17399272 64,Afghanistan,2010,AFG,31411743.0,4.75838089,1614.25500126 65,Afghanistan,2011,AFG,32358260.0,3.83171916,1660.73985618 66,Afghanistan

R Shiny + plotly : change color of a trace with javascript without affecting markers and legend in multiple plots

无人久伴 提交于 2019-12-04 05:47:42
问题 This is a follow up question based on THIS post. The demo app here is a closer representation of my more complex situation of my real shiny app that I'm trying to improve by replacing code that causes re- rendering of plotly objects by javascript codes that alter the existing plots . This app has: - 4 plots with unique ID's - sets of 2 plots listen to the same set of colourInputs , 1 for each trace in each plot - the legend and marker size in all plots are linked to numericInputs The

ggplotly - R, labeling trace names

跟風遠走 提交于 2019-12-04 05:40:35
I'm new to plotly and not able to find the relevant documentation on how to name the traces so a meaningful label appears in plot rendered by ggplotly . Here is the ggplotly site that shows a number of examples. What is needed to show a meaningful label on hover instead of the value followed by trace0, trace1, etc. For example, in the first plot, how can the labels appear so it shows: Proportion: value Total bill: value Ideally, I would like to do this directly in R rather than through the web interface. Thanks in advance. You can also edit any of the plotly figure properties after the ggplot2

plotly basic example shows no plot in jupyter lab

╄→尐↘猪︶ㄣ 提交于 2019-12-04 04:41:42
问题 I just tried to use plotly offline in a jupyter notebook (using jupyter lab). The docs gives this example: import plotly import plotly.graph_objs as go plotly.offline.init_notebook_mode(connected=True) plotly.offline.iplot({ "data": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])], "layout": go.Layout(title="hello world") }) I tried it and there is no chart displayed, either in Edge or Firefox. An output cell is made in the notebook, but there is no chart. It works if I use plotly.offline.plot

Change size of hover text in Plotly

房东的猫 提交于 2019-12-04 04:32:48
I am building a Plotly plot based on a ggplot in R. I would like to increase the size of the text in the hover boxes. Suppose I have a scatterplot like this: library(plotly) library(ggplot2) d <- data.frame(a = sample(1:50, 30, T), b = sample(1:50, 30, T), col = factor(sample(1:3, 30, T))) gg <- ggplot() + geom_point(aes(x = a, y = b, color = col), data = d) p <– plotly_build(gg) p Is there a way to change the size of the hover text? Currently there seems to be no built-in way to pass additional attributes to define the hover appearance directly via plotly (see github issue #102 ). However, in

How to rotate the dial in a gauge chart? Using python plotly

限于喜欢 提交于 2019-12-04 04:32:43
问题 I am recently into using plotly package for a gauge chart in python. After going through the tutorial and template here, I wonder if there is a way to rotate the "dial" or "needle" given a angle value? Someone has suggested me using css: transform to do the trick, but still it's hard for me to know how to apply css to the plotly script. A short and simple code would be great. Thank you in advance. 回答1: A bit late to this question. My solution to this problem, though it still needs work is: I

ImportError: 'No module named plotly.plotly' in LinuxMint17.3

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 03:52:18
I am New in Python. Whenever I am trying to compile the following code to get a line graph shows some errors. But I don't know how to fix it. Here is my code : import plotly.plotly as py import plotly.graph_objs as go # Create random data with numpy import numpy as np N = 500 random_x = np.linspace(0, 1, N) random_y = np.random.randn(N) # Create a trace trace = go.Scatter( x = random_x, y = random_y ) data = [trace] py.iplot(data, filename='basic-line') Shows the following error : mks@mks-H81M-S /media/mks/KUTUBUDDIN1/test $ python datdaPlot.py Traceback (most recent call last): File