Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected output/plot created when using scattergl instead of scatter #412

Closed
cchrysostomou opened this issue Apr 11, 2016 · 1 comment
Closed

Comments

@cchrysostomou
Copy link

Scattergl appears to not be working the same as scatter function. I have found two issues when using scattergl.

  1. When I turn hoverinfo to 'none', rather than not getting hovertips, I instead get two intersecting lines on the plot which follow the crosshairs.
  2. I cannot seem to plot multiple yaxes and xaxes when using scattergl, but I can get it to work using just scatter.

Here is code demonstrating the issue

Note this code was taken from the tutorial provided here: https://plot.ly/python/2d-density-plots/

Using scatter function will work as expected: There will be no hover info and all plots will appear

import plotly.offline as py
import plotly.graph_objs as go
import matplotlib
%matplotlib inline
py.init_notebook_mode()

import numpy as np

t = np.linspace(-1,1.2,2000)
x = (t3)+(0.3*np.random.randn(2000))
y = (t
6)+(0.3*np.random.randn(2000))

trace1 = go.Scatter(
x=x, y=y, mode='markers', name='points',
marker=dict(color='rgb(102,0,0)', size=2, opacity=0.4),
hoverinfo='none'

)
trace2 = go.Histogram2dcontour(
x=x, y=y, name='density', ncontours=20,
colorscale='Hot', reversescale=True, showscale=False,
hoverinfo='none'

)
trace3 = go.Histogram(
x=x, name='x density',
marker=dict(color='rgb(102,0,0)'),
yaxis='y2'
)
trace4 = go.Histogram(
y=y, name='y density', marker=dict(color='rgb(102,0,0)'),
xaxis='x2'
)
data = [trace1, trace2, trace3, trace4]

layout = go.Layout(
showlegend=False,
autosize=False,
width=600,
height=550,
xaxis=dict(
domain=[0, 0.85],
showgrid=False,
zeroline=False
),
yaxis=dict(
domain=[0, 0.85],
showgrid=False,
zeroline=False
),
margin=dict(
t=50
),
hovermode='closest',
bargap=0,
xaxis2=dict(
domain=[0.85, 1],
showgrid=False,
zeroline=False
),
yaxis2=dict(
domain=[0.85, 1],
showgrid=False,
zeroline=False
),
)

fig = go.Figure(data=data, layout=layout)
py.offline.iplot(fig)

Now if I were to repeat the same code using scattergl, then I will not not be able to see the histograms anymore and there will be two lines following the crosshair

import plotly.offline as py
import plotly.graph_objs as go
import matplotlib
%matplotlib inline
py.init_notebook_mode()

import numpy as np

t = np.linspace(-1,1.2,2000)
x = (t3)+(0.3*np.random.randn(2000))
y = (t
6)+(0.3*np.random.randn(2000))

trace1 = go.Scattergl(
x=x, y=y, mode='markers', name='points',
marker=dict(color='rgb(102,0,0)', size=2, opacity=0.4),
hoverinfo='none'

)
trace2 = go.Histogram2dcontour(
x=x, y=y, name='density', ncontours=20,
colorscale='Hot', reversescale=True, showscale=False,
hoverinfo='none'

)
trace3 = go.Histogram(
x=x, name='x density',
marker=dict(color='rgb(102,0,0)'),
yaxis='y2'
)
trace4 = go.Histogram(
y=y, name='y density', marker=dict(color='rgb(102,0,0)'),
xaxis='x2'
)
data = [trace1, trace2, trace3, trace4]

layout = go.Layout(
showlegend=False,
autosize=False,
width=600,
height=550,
xaxis=dict(
domain=[0, 0.85],
showgrid=False,
zeroline=False
),
yaxis=dict(
domain=[0, 0.85],
showgrid=False,
zeroline=False
),
margin=dict(
t=50
),
hovermode='closest',
bargap=0,
xaxis2=dict(
domain=[0.85, 1],
showgrid=False,
zeroline=False
),
yaxis2=dict(
domain=[0.85, 1],
showgrid=False,
zeroline=False
),
)

fig = go.Figure(data=data, layout=layout)
py.offline.iplot(fig)

@etpinard
Copy link
Contributor

duplicate of #130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants