Andrey
Andrey

Reputation: 13

Plotting the graph on the complex plain

I would like to plot the graphic of function: w(s) = 1/(1+s).

s is the product of the imaginary unit (1j) and the variable called omega; i.e. s = 1j*omega.

How I can plot that in the complex axis (Real and Imaginary) using Python (2.7 or 3.4) and matplotlib?

Upvotes: 1

Views: 2431

Answers (1)

xnx
xnx

Reputation: 25518

You're not clear in your question about what you want to plot, but assuming omega = x + iy is the number you wish to plot w(s) as a function of, you have to decide how to present the complex numbers w(s). You might choose a plot with Cartesian axes representing the real (x) and imaginary (y) axes and to plot the absolute value of w(s) as a colour, or you might choose to plot the real and imaginary parts separately. For example,

import matplotlib as plt
import numpy as np

x = np.linspace(-0.5,0.5,100)
y = np.linspace(-3,0,100)
X, Y = np.meshgrid(x,y)

def f(x, y):
    return 1./(1+1j*(x+1j*y))

import pylab
pylab.imshow(np.abs(f(X,Y)))
pylab.show()

enter image description here

Upvotes: 1

Related Questions