Show Sidebar Hide Sidebar

Logarithmic Colorscale in Python

How to make Tables in Python with Plotly.

Logarithmic Colorscale

Learn how to create a logarithmic colorscale for a plotly graph in python.

Learn about API authentication here: https://plot.ly/python/getting-started
Find your api_key here: https://plot.ly/settings/api

In [60]:
import plotly.plotly as py
import math

data = [{
    'z': [[10, 100.625, 1200.5, 150.625, 2000],
           [5000.625, 60.25, 8.125, 100000, 150.625],
           [2000.5, 300.125, 50., 8.125, 12.5],
           [10.625, 1.25, 3.125, 6000.25, 100.625],
           [0, 0.625, 2.5, 50000.625, 10]],
    'type': 'heatmap',
    'colorscale': [
        [0, 'rgb(250, 250, 250)'],        #0
        [1./10000, 'rgb(200, 200, 200)'], #10
        [1./1000, 'rgb(150, 150, 150)'],  #100
        [1./100, 'rgb(100, 100, 100)'],   #1000
        [1./10, 'rgb(50, 50, 50)'],       #10000
        [1., 'rgb(0, 0, 0)'],             #100000

    ],
    'colorbar': {
        'tick0': 0,
        'tickmode': 'array',
        'tickvals': [0, 1000, 10000, 100000]
    }
    }]

layout = {'title': 'Log Colorscale'}

fig = {'data': data, 'layout': layout}

py.iplot(fig, filename='docs/log-colorscale')
Out[60]:
For more information, check out our python figure reference page!
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to our Premium or Enterprise plans.