plotly

Color code a scatter plot by group with a gradient

痞子三分冷 提交于 2019-12-05 21:44:10
I have XY data which I'd like to graph using a scatter plot , with R 's plotly package. set.seed(1) df <- data.frame(x=c(rnorm(30,1,1),rnorm(30,5,1),rnorm(30,9,1)), y=c(rnorm(30,1,1),rnorm(30,5,1),rnorm(30,9,1)), group=c(rep("A",30),rep("B",30),rep("C",30)),score=runif(90,0,1)) Each point is assigned to one of three groups ( df$group ) and has a score in the [0,1] range. I'm looking for a way to graph the data such that each group is colored with a different color but the shade of that color (or intensity) reflects the score. So I thought this would work: library(dplyr) library(plotly) plot_ly

python plotly: how to make a choropleth map with a slider (access grid data issue)

筅森魡賤 提交于 2019-12-05 21:31:25
I want to draw a choropleth world map with a slider for the year values. It would be a combination of the "Choropleth Map" and the "Adding Sliders to Animations" ( https://plot.ly/python/ ). First I searched plotly's community forum and the web for an example of a plotly choropleth map with grid data or a slider without success. While I managed to replicate the slider animation example with my data (see jupyter notebook link below), adapting the choropleth code to access grid data with a slider does not seem to work. In contrast to a regular map (like in example one), data is not loaded from a

Error with embed_notebook, getting plotly to work on Jupyter

自闭症网瘾萝莉.ら 提交于 2019-12-05 20:36:05
I am trying to have embedded R plotly charts in Jupyter I am following https://plot.ly/r/using-r-in-jupyter-notebooks/ But stuck at "Make sure that both pandoc.exe and pandoc-citeproc are available in your local python installation folder (or Jupyter environment if you have setup a separate environment)." I found the pandoc.exe and pandoc-citeproc. But not sure on where to copy those files. Based on the Anaconda Prompt my environment is C:\Users\myname\AppData\Local\Continuum\Anaconda2\ But even after copying the files there I still get the error of: "Error in embed_notebook(gg): x must be a

Double x axis (analog to doubleYScale) with lattice extra or similar

拟墨画扇 提交于 2019-12-05 20:03:59
I want to make specific figures that we need in oceanography. Unfortunately double, triple or more axes are not very good implemented in R. I don't need a double y axis as in doubleYScale of lattice extra. I need double or triple x axis. I could not find a way to use doubleYScale to my advantage. Maybe that's possible. Help would be appreciated a lot. This is what I have now based on the data: stackoverflow_fluo.csv: http://pastebin.com/embed_js.php?i=7KNEiytF animals_stackoverflow.csv: http://pastebin.com/embed_js.php?i=CnEJaq6b Important update: I forgot to mention that the depth values on

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

孤者浪人 提交于 2019-12-05 20:03:17
问题 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

manually set colors per group in barplot ggplot

故事扮演 提交于 2019-12-05 19:03:51
I need to manually set colors for each group in a barplot. I currently have the fill = time and this is currently determining the colors. We have 5 brands and the values for 2 separate months per brand. I need to group by brand but also need a way to display which bar represents which month(time), I can currently do this however I want to color each bar group. eg. brand1 bars = red, brand2 bars = blue ect whilst still having fill = time Here is my code: colors <- c("#98999B", "#F4C400", "#CB003D", "#6BABE5", "#E65400", "#542C82") time <- c("February 2017","March 2017","February 2017","March

How to plot vertical lines in plotly offline?

谁说我不能喝 提交于 2019-12-05 18:24:09
How would one plot a vertical line in plotly offline, using python? I want to add lines at x=20, x=40, and x=60, all in the same plot. def graph_contracts(self): trace1 = go.Scatter( x=np.array(range(len(all_prices))), y=np.array(all_prices), mode='markers', marker=dict(size=10, color='rgba(152, 0, 0, .8)')) data = [trace1] layout = go.Layout(title='Market Contracts by Period', xaxis=dict(title='Contract #', titlefont=dict(family='Courier New, monospace', size=18, color='#7f7f7f')), yaxis=dict(title='Prices ($)', titlefont=dict(family='Courier New, monospace', size=18, color='#7f7f7f'))) fig =

Plotly R: setting the spacing between axis label and axis ticks labels

六月ゝ 毕业季﹏ 提交于 2019-12-05 18:01:44
问题 Is there any way to set a spacing between axis labels and axis ticks labels other than changing margins? Example plot: plot_ly(mtcars, x = ~ wt, y = ~ paste0(hp, '0000')) As in the example plot above the title of the y axis is overlapping tick labels of this axis. Is there a way to set a spacing between them? 回答1: Increasing the left margin as @Codutie suggests in his answer does help to a certain degree only (at least in Plotly v4.7.1+). Most of the 150 pixel margin on the left is wasted

Plotly: How to make stacked bar chart from single trace?

风格不统一 提交于 2019-12-05 17:33:05
Is it possible to have two stacked bar charts side by side each of them coming from a single column? Here's my df: Field Issue Police Budget cuts Research Budget cuts Police Time consuming Banking Lack of support Healthcare Lack of support Research Bureaucracy Healthcare Bureaucracy Banking Budget cuts I want a stacked bar chart of Field next to a stacked bar chart of issues by field. Thanks guys! For an example on how to make a stacked bar chart with the specific dataset provided, take a look at the suggestion in Plotly-Dash: Want two stacked bar charts side by side from single df column .

Update plotly in R without recreating widget when plotted data is altered

戏子无情 提交于 2019-12-05 15:45:41
Everytime a plotly object is created by R in shiny, (or just in R), the widget is recreated completely. For small data sets this is not a problem, but i'm working with plots that contain thousands of scatter points, making it take 10-20 seconds to recreate a plot in my shinyapp. I'm looking for a way to update the data through a javascript solution that doesn't trigger the widget to be rebuild, but simply replaces it's data. Here is a dummy app with 2 small data sets between which the app can switch. In the dummy app it does it by recreating the widget. Quite fast here due to the limited