简体   繁体   中英

Python: Plotly: Parallel Coordinates Opacity

Im trying to do a parallel coordinate plot. I want the color of the lines black, but with an opacity so that lines which overlap are darker than the rest. Is it possible to set an opcaity to the color in the example of plotly parallel coordinates ?

import plotly.plotly as py
import plotly.graph_objs as go

import pandas as pd 

df = pd.read_csv("https://raw.githubusercontent.com/bcdunbar/datasets/master/parcoords_data.csv")

data = [
    go.Parcoords(
        line = dict(color = df['colorVal'],
                   colorscale = 'Jet',
                   showscale = True,
                   reversescale = True,
                   cmin = -4000,
                   cmax = -100),
        dimensions = list([
            dict(range = [32000,227900],
                 constraintrange = [100000,150000],
                 label = 'Block Height', values = df['blockHeight']),
            dict(range = [0,700000],
                 label = 'Block Width', values = df['blockWidth']),
            dict(tickvals = [0,0.5,1,2,3],
                 ticktext = ['A','AB','B','Y','Z'],
                 label = 'Cyclinder Material', values = df['cycMaterial']),
            dict(range = [-1,4],
                 tickvals = [0,1,2,3],
                 label = 'Block Material', values = df['blockMaterial']),
            dict(range = [134,3154],
                 visible = True,
                 label = 'Total Weight', values = df['totalWeight']),
            dict(range = [9,19984],
                 label = 'Assembly Penalty Weight', values = df['assemblyPW']),
            dict(range = [49000,568000],
                 label = 'Height st Width', values = df['HstW']),
            dict(range = [-28000,196430],
                 label = 'Min Height Width', values = df['minHW']),
            dict(range = [98453,501789],
                 label = 'Min Width Diameter', values = df['minWD']),
            dict(range = [1417,107154],
                 label = 'RF Block', values = df['rfBlock'])
        ])
    )
]

py.offline.plot(data, filename = 'parcoords-advanced')

plotly 2.1.0 needs import plotly as py

It looks impossible. The reason is as the follows for there is no any option that is related to "opacity":

Valid attributes for 'line' at path ['line'] under parents ['parcoords']:

['autocolorscale', 'cauto', 'cmax', 'cmin', 'color', 'colorbar',
'colorscale', 'colorsrc', 'reversescale', 'showscale']

Valid attributes for 'dimension' at path ['dimensions'][3] under parents ['parcoords', 'dimensions']:

['constraintrange', 'label', 'range', 'tickformat', 'ticktext',
'ticktextsrc', 'tickvals', 'tickvalssrc', 'values', 'valuessrc',
'visible']

However https://plot.ly/python/line-and-scatter/ mentioned "opacity" that might be in another package of plotly

You can try R's plot or matplotlib.pyplot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM