Created
November 28, 2018 05:36
-
-
Save shunkino/74343f2ea3e5a3c5281ab1b0b8df7969 to your computer and use it in GitHub Desktop.
color scale converter file for my blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objs as go | |
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot | |
import numpy as np | |
import colorlover as cl | |
def convert_colorscale_format(colorscale): | |
plotly_colorscale = [] | |
for index, sec_value in enumerate(np.linspace(0, 1, len(colorscale))): | |
plotly_colorscale.append([sec_value, colorscale[index]]) | |
return plotly_colorscale | |
# %% | |
N = 10000 | |
cluster_id = [np.random.randint(N/1000) for val in range(N)] | |
trace = go.Scattergl( | |
x = np.random.randn(N), | |
y = np.random.randn(N), | |
mode = 'markers', | |
marker = dict( | |
colorscale=convert_colorscale_format(cl.scales['12']['qual']['Set3']), | |
color=cluster_id, | |
line = dict( | |
width = 1, | |
color = '#404040') | |
) | |
) | |
data = [trace] | |
iplot(data, filename='WebGL100000') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment