2d Histogram with log axes supported?

Histogram plots seem to not like logarithmic axes… I’m working on 2d histograms at the moment, but I recall seeing something similar for 1d histograms as well.

See example below where I generate data that is hard to see with linear-type axes. Same data set plotted twice. The first histogram has linear axes, and the second one has log axes.

The histogram2d gets blown away with log axes… only the scatter plot remains visible.

Is this my code doing something bad or is this a bug in the Plotly backend?

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import numpy as np

app = dash.Dash()

# Create some dummy data that spans orders of magnitude
t = np.linspace(1,1.2,2000)
x = (t**3)+(0.3*np.random.randn(2000))
y = (np.exp(4*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))
trace2 = go.Histogram2dcontour(x=x, y=y, name='density', ncontours=20,
                    colorscale='YIGnBu', reversescale=False, showscale=False)
data = [trace1, trace2]

# create a layout with linear axes
layout_linear = go.Layout(

# and one with logarithmic axes
layout_log = go.Layout(

fig_linear = go.Figure(data=data,layout=layout_linear)
fig_log    = go.Figure(data=data,layout=layout_log)

app.layout = html.Div([
    dcc.Markdown("### Not using log axis"),
    dcc.Markdown("### Same data, using log axis:"),

if __name__=='__main__':

Here are the plots:

This looks like a bug in plotly.js. Thanks for reporting! I’ve created an issue in plotly.js here: https://github.com/plotly/plotly.js/issues/1844

1 Like