Pandas plotting function parallel_coordinates() in Python
The Pandas plotting function parallel_coordinates() used to plot parallel coordinates. It returns a matplotlib.axes.Axes.
Syntax
 1 pandas.plotting.parallel_coordinates(frame, class_column, cols = None, ax = None, color = None, use_columns = False,
 2  xticks = None, colormap = None, axvlines = True, axvlines_kwds = None, sort_labels = False, **kwargs)
frame : It is an object of DataFrame
clas_column : It is a string that represents the column name containing class names.
cols : It is a list of column names to use.
ax : It is a matplotlib.axis object.
color : It can be list or tuple that specifies a colors to use for the different classes.
use_columns : It is a boolean that specifies whether to use columns as xticks.
xticks : It can be list or tuple to use for xticks.
colormap : It is a string or matplotlib colormap to use for line color. If not specified, the default value will be None.
axvlines : It is a boolean that specifies the vertical lines will be added at each xtick.
axvline_kwds : It specifies an addition keywords to be passed to axvline method for vertical lines.
sort_labels : It is a boolean value that sort class_column labels and used when assigning colors.
**kwargs : It specifies an additional keywords to be passed to the function.
CSV file content
 1 R1,R2,R3,R4
 2 5.1,3.5,1.4,0.2,A
 3 4.9,3,1.4,0.2,A
 4 4.7,3.2,1.3,0.2,A
 5 4.6,3.1,1.5,0.2,A
 6 5,3.6,1.4,0.2,A
 7 5.4,3.9,1.7,0.2,B
 8 4.6,3.4,1.4,0.4,B
 9 5,3.4,1.5,0.3,B
 10 4.4,2.9,1.4,0.2,B
 11 4.0,2.1,1.5,0.1,B
 12 5.1,3.5,1.4,0.2,D
 13 4.9,3,1.4,0.2,D
 14 4.7,3.2,1.3,0.2,C
 15 4.6,3.1,1.5,0.2,C
 16 5,3.6,1.4,0.2,C
 17 5.4,3.9,1.7,0.2,C
 18 4.6,3.4,1.4,0.6,B
 19 5,3.4,1.5,0.3,C
 20 4.4,2.9,1.4,0.2,D
 21 4.0,2.1,1.5,0.1,D
parallel_coordinates() function
 1 import pandas as pd
 2 import numpy as np
 3 import matplotlib.pyplot as plt
 4 
 5 df = pd.read_csv('C:\\Users\\username\\data.csv')
 6 res = pd.plotting.parallel_coordinates(df, 'R4',
 7             color = ('#bcbe00', '#f17300', '#7173f0', '#71cb90'))  
 8 
 9 res.plot()
 10 plt.show()
In the above example, a DataFrame object is created by reading csv file. A parallel_coordinates() function is called that returns matplotlib objct that plot on graph that will be visible on popup.
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us