How to plot a complex number in Python using Matplotlib ? Last Updated : 03 Jan, 2021 Comments Improve Suggest changes Like Article Like Report In this article we will learn how to plot complex number in Python using Matplotlib. Let's discuss some concepts : Matplotlib : Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. It was introduced by John Hunter in the year 2002.Complex number : A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers, and i represents the imaginary unit, satisfying the equation i2 = −1. Because no real number satisfies this equation, i is called an imaginary number.Complex number in Python : An complex number is represented by “ x + yi “. Python converts the real numbers x and y into complex using the function complex(x,y). The real part can be accessed using the function real() and imaginary part can be represented by imag(). Approach: Import libraries.Create data of complex numbersExtract real and imaginary parts from complex numbers dataPlot the extracted data. Examples: To plot complex numbers, we have to extract its real and imaginary part and to extract and create data, we will use some methods that are explained in below examples : Example 1 : (Simple plot with complex numbers over real and imaginary data) Python3 # import library import matplotlib.pyplot as plt # create data of complex numbers data = [1+2j, -1+4j, 4+3j, -4, 2-1j, 3+9j, -2+6j, 5] # extract real part x = [ele.real for ele in data] # extract imaginary part y = [ele.imag for ele in data] # plot the complex numbers plt.scatter(x, y) plt.ylabel('Imaginary') plt.xlabel('Real') plt.show() Output : Example 2 : (Using numpy for extracting real and imaginary parts) Python3 # import libraries import matplotlib.pyplot as plt import numpy as np # create data of complex numbers data = np.array([1+2j, 2-4j, -2j, -4, 4+1j, 3+8j, -2-6j, 5]) # extract real part using numpy array x = data.real # extract imaginary part using numpy array y = data.imag # plot the complex numbers plt.plot(x, y, 'g*') plt.ylabel('Imaginary') plt.xlabel('Real') plt.show() Output : Example 3 : (Using numpy for creating data of complex numbers and extracting real and imaginary parts) Python3 # import libraries import matplotlib.pyplot as plt import numpy as np # create data of complex numbers using numpy data = np.arange(8) + 1j*np.arange(-4, 4) # extract real part using numpy x = data.real # extract imaginary part using numpy y = data.imag # plot the complex numbers plt.plot(x, y, '-.r*') plt.ylabel('Imaginary') plt.xlabel('Real') plt.show() Output : Comment More infoAdvertise with us Next Article How to plot a complex number in Python using Matplotlib ? D deepanshu_rustagi Follow Improve Article Tags : Python Python-matplotlib Practice Tags : python Similar Reads How to Plot Mfcc in Python Using Matplotlib? Mel-frequency cepstral coefficients (MFCC) are widely used in audio signal processing and speech recognition tasks. They represent the spectral characteristics of an audio signal and are commonly used as features for various machine-learning applications. In this article, we will explore how to comp 2 min read How to plot a normal distribution with Matplotlib in Python? Normal distribution, also known as the Gaussian distribution, is a fundamental concept in probability theory and statistics. It is a symmetric, bell-shaped curve that describes how data values are distributed around the mean. The probability density function (PDF) of a normal distribution is given b 4 min read Multiply matrices of complex numbers using NumPy in Python In this article, we will discuss how to multiply two matrices containing complex numbers using NumPy but first, let's know what is a complex number. A Complex Number is any number that can be represented in the form of x+yj where x is the real part and y is the imaginary part. Multiplication of two 2 min read Plotting Sine and Cosine Graph using Matplotlib in Python Data visualization and Plotting is an essential skill that allows us to spot trends in data and outliers. With the help of plots, we can easily discover and present useful information about the data. In this article, we are going to plot a sine and cosine graph using Matplotlib in Python. Matplotlib 3 min read Contour Plot using Matplotlib - Python Contour plots also called level plots are a tool for doing multivariate analysis and visualizing 3-D plots in 2-D space. If we consider X and Y as our variables we want to plot then the response Z will be plotted as slices on the X-Y plane due to which contours are sometimes referred as Z-slices or 2 min read Like