Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Data preprocessing
  • Data Manipulation
  • Data Analysis using Pandas
  • EDA
  • Pandas Exercise
  • Pandas AI
  • Numpy
  • Matplotlib
  • Plotly
  • Data Analysis
  • Machine Learning
  • Data science
Open In App
Next Article:
How to plot Andrews curves using Pandas in Python?
Next article icon

How to plot Andrews curves using Pandas in Python?

Last Updated : 21 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Andrews curves are used for visualizing high-dimensional data by mapping each observation onto a function. It preserves means, distance, and variances. It is given by formula:

T(n) = x_1/sqrt(2) + x_2 sin(n) + x_3 cos(n) + x_4 sin(2n) + x_5 cos(2n) + …

Plotting Andrews curves on a graph can be done using the andrews_curves() method of the plotting module. This function generates a matplotlib plot of Andrews curves, for visualising clusters of multivariate data.

Syntax: andrews_curves(frame, class_column, ax=None, samples=200, color=None, colormap=None, **kwargs)

Parameters:

  • frame: It is the data to be plotted.
  • class_column: This is the name of the column containing class names.
  • ax: This parameter is a matplotlib axes object. Its default value is None.
  • samples: This parameter is the number of points to plot in each curve.
  • color: This parameter is an optional parameter and it is the list or tuple of colors to use for the different classes.
  • colormap: This parameter is the string/matplotlib colormap object. Its default value is None.

Returns: This function returns an object of class matplotlib.axis.Axes

Example 1: In the following example, A data frame is made from the CSV file and the data frame is used to plot andrews_curves.

Python3
# importing various package import pandas as pd import numpy as np import matplotlib.pyplot as plt  # making data frame from csv file df = pd.read_csv(     'C:\\Users\\digital india\\Desktop\\pand.csv' )  # Creating Andrews curves x = pd.plotting.andrews_curves(df, 'animal')  # plotting the Curve x.plot()  # Display plt.show()  

Output:

Example 2: 

Python3
# importing various package import pandas as pd import numpy as np import matplotlib.pyplot as plt  # making data frame from csv file df = pd.read_csv(     'https://raw.github.com/pandas-dev/'     'pandas/master/pandas/tests/io/data/csv/iris.csv' )  # Creating Andrews curves x = pd.plotting.andrews_curves(df, 'Name')  # plotting the Curve x.plot()  # Display plt.show()  

Output:


Next Article
How to plot Andrews curves using Pandas in Python?

S

SHUBHAMSINGH10
Improve
Article Tags :
  • Python
  • Python-pandas
  • Python pandas-plotting
Practice Tags :
  • python

Similar Reads

    How to Plot a Dataframe using Pandas
    Pandas plotting is an interface to Matplotlib, that allows to generate high-quality plots directly from a DataFrame or Series. The .plot() method is the core function for plotting data in Pandas. Depending on the kind of plot we want to create, we can specify various parameters such as plot type (ki
    8 min read
    How to plot Timeseries based charts using Pandas?
    A series of data points collected over the course of a time period, and that are time-indexed is known as Time Series data. These observations are recorded at successive equally spaced points in time. For Example, the ECG Signal, EEG Signal, Stock Market, Weather Data, etc., all are time-indexed and
    10 min read
    How to plot ricker curve using SciPy - Python?
    Prerequisites: Mathplotlib, NumPy A Ricker wavelet is a wave-like oscillation with an amplitude that begins at 0, increases, and then decreases back to 0. A Ricker wavelet, also known as the “Mexican hat wavelet”.In this article, we will plot the ricker curve that makes them useful for signal proces
    2 min read
    How To Make Density Plot in Python with Altair?
    Density plots are a variation of Histograms that are used to observe the distribution of a variable in data set over a continuous interval or a time period. The peaks of a Density Plot indicate where values are concentrated over an interval. Compared to Histograms, Density Plots are better at determ
    2 min read
    Plot Candlestick Chart using mplfinance module in Python
    Candlestick chart are also known as a Japanese chart. These are widely used for technical analysis in trading as they visualize the price size within a period. They have four points Open, High, Low, Close (OHLC). Candlestick charts can be created in python using a matplotlib module called mplfinance
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences