plotly

How to plot vertical lines in plotly offline?

孤街醉人 提交于 2020-01-02 06:34:08
问题 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

Plotting a grouped pandas data in plotly

荒凉一梦 提交于 2020-01-02 05:13:24
问题 I have a pandas dataframe which looks like this: A B 1 USA Y 3 USA Y 4 USA N 5 India Y 8 India N 12 USA N 14 USA Y 19 USA Y I want to make a countplot for this dataframe. That is, the plot will have country names on X-axis and the counts for each category on Y-axis . I know I can do this in seaborn like this: sns.countplot(x='A', data=df, hue='B') But this will not be an interactive plot. I want to achieve the same thing in plotly but I am having a hard time figuring it out. Can anyone please

How to set plotly chart to have a transparent background in R?

北慕城南 提交于 2020-01-02 02:21:29
问题 Here's what I have, so far: f1 <- list( family = "Arial, sans-serif", size = 25, color = "white" ) f2 <- list( family = "Old Standard TT, serif", size = 14, color = "black" ) a <- list( title = "SALES PER SONG", titlefont = f1, showgrid = FALSE, showticklabels = TRUE, showline=TRUE, tickangle = 45, tickfont = f2 ) salesplot <-plot_ly(producersales, type="scatter", x=Producer, y=SalesPerSong, color=SongRange, colors=cols, mode="markers", size=SalesPerSong) %>% layout(xaxis = a, yaxis = a) I

How do I display a website written in Dash as a static PDF (Python)?

我们两清 提交于 2020-01-02 01:59:11
问题 I want to export the site I've made in dash into a static PDF. Here is the code for my site (it's just a chart with 3 columns): import dash import dash_core_components as dcc import dash_html_components as html import pdfkit from flask import Flask, render_template, make_response app = dash.Dash() app.layout = html.Div( className="three columns", children=html.Div([ dcc.Graph( id='right-top-graph', figure={ 'data': [{ 'x': [1, 2, 3], 'y': [3, 1, 2], 'type': 'bar' }], 'layout': { 'height': 400

Plotly: Grouped Bar Chart with multiple axes

巧了我就是萌 提交于 2020-01-02 01:07:56
问题 When I set barmode='group' in Layout while trace2 = Bar(...,yaxis='y2') , this leads bars to be stacked or overlayed instead of grouping them. How can I group the bars while having multiple axes? I went over these but no avail: With single Y axis grouped bar chart is shown here. Multiple axes is also explained here and reference for y-axis is available here 回答1: Here's an example of a grouped bar charts with multiple axes: https://plot.ly/~etpinard/2080/grouped-bars-on-multiple-axes/ The

Interactively adding points to plotly R without redrawing background plot

烂漫一生 提交于 2020-01-01 19:22:05
问题 The MWE below oversimplifies my real goal. However, I have a background image that takes a long time to draw (in the example below it is simply a scatterplot of 32 mtcars dataset values). Users can click on certain points from my background image, and this will cause new points to be plotted. My aim is for these new points to simply be redrawn on the top layer, while the background image scatterplot does not need to be redrawn to save time and computation. My MWE is as follows: library(plotly

Multiple y-axes chart with Plotly in R

巧了我就是萌 提交于 2020-01-01 09:12:56
问题 In Plotly for Python, we have this beautiful multiple y-axis example: here is the link for the code. I tried to do the same with Plotly in R using this code: library(plotly) x <- 1:4 y1 <- c(1,2,3,4) y2 <- c(4,3,2,1) y3 <- c(1,4,1,4) y4 <- c(4,1,4,1) test <- data.frame(x, y1, y2, y3, y4) plot_ly(data = test, x = ~x, y = ~y1 ,type = "scatter", mode = "lines", width = 800, color = I("red") ,name = "name01") %>% add_trace(x = ~x, y = ~y2, yaxis = "y2", color = I("blue"), name = "name02") %>% add

Plotly in Jupyter issue

烈酒焚心 提交于 2020-01-01 08:45:48
问题 I installed plotly.py to work some plots using Jupyter but I cannot import it. ! pip install plotly --upgrade Requirement already up-to-date: plotly in c:\python34\lib\site-packages Requirement already up-to-date: requests in c:\python34\lib\site-packages (from plotly) Requirement already up-to-date: six in c:\python34\lib\site-packages (from plotly) Requirement already up-to-date: pytz in c:\python34\lib\site-packages (from plotly) Cleaning up... and then import plotly ----------------------

Plotly in Jupyter issue

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 08:45:26
问题 I installed plotly.py to work some plots using Jupyter but I cannot import it. ! pip install plotly --upgrade Requirement already up-to-date: plotly in c:\python34\lib\site-packages Requirement already up-to-date: requests in c:\python34\lib\site-packages (from plotly) Requirement already up-to-date: six in c:\python34\lib\site-packages (from plotly) Requirement already up-to-date: pytz in c:\python34\lib\site-packages (from plotly) Cleaning up... and then import plotly ----------------------

Plotly.js: How to avoid overlapping contour lines?

余生颓废 提交于 2020-01-01 07:23:05
问题 Below is an example for creating a contour plot with plotly.js. Some of the contour lines overlap . How can I alter the plotly settings to avoid that (e.g. increase resolution , switch contouring algorithm )? If I plot the same data using conrec.js the contours do not overlap. A. Conrec.js (this works, no overlap) Source code for the example: https://github.com/jasondavies/conrec.js/tree/master/example B. Plotly.js (does not work: overlapping contours) Source code for the example: https:/