Note
Click here to download the full example code
07a. Manufacturing features (parallel)
This Python script uses the pandas and Plotly libraries to create an interactive parallel coordinates plot. This type of plot is excellent for visualizing and exploring relationships in datasets with many variables (high-dimensional data). Each vertical line represents a different variable (a column from the dataset), and each colored line that snakes across the plot represents a single data point (a row from the dataset).
14 import plotly.graph_objects as go
15 import pandas as pd
16
17 from plotly.io import show
18
19 try:
20 __file__
21 TERMINAL = True
22 except:
23 TERMINAL = False
24
25
26 # Load
27 df = pd.read_csv("https://raw.githubusercontent.com/bcdunbar/datasets/master/parcoords_data.csv")
28
29 # Visualize
30 if TERMINAL:
31 print("\nData:")
32 print(df)
33 df
34
35 # Show
36 fig = go.Figure(data=
37 go.Parcoords(
38 line = dict(color = df['colorVal'],
39 colorscale = 'Electric',
40 showscale = True,
41 cmin = -4000,
42 cmax = -100),
43 dimensions = list([
44 dict(range = [32000,227900],
45 constraintrange = [100000,150000],
46 label = "Block Height", values = df['blockHeight']),
47 dict(range = [0,700000],
48 label = 'Block Width', values = df['blockWidth']),
49 dict(tickvals = [0,0.5,1,2,3],
50 ticktext = ['A','AB','B','Y','Z'],
51 label = 'Cyclinder Material', values = df['cycMaterial']),
52 dict(range = [-1,4],
53 tickvals = [0,1,2,3],
54 label = 'Block Material', values = df['blockMaterial']),
55 dict(range = [134,3154],
56 visible = True,
57 label = 'Total Weight', values = df['totalWeight']),
58 dict(range = [9,19984],
59 label = 'Assembly Penalty Wt', values = df['assemblyPW']),
60 dict(range = [49000,568000],
61 label = 'Height st Width', values = df['HstW'])])
62 )
63 )
64
65 # Show
66 show(fig)
Total running time of the script: ( 0 minutes 3.521 seconds)