简体   繁体   中英

Python Program to rotate a complex no by 180

I want to rotate a complex no by 180° and this code is in my textbook but it gives me a error everytime

import matplotlib.pyplot as plt
x = 2 + 4j
plt.scatter (x.real, x.imag, color='red')
plt.scatter (-1 x.real, -1 x.imag, color = 'blue')
plt.show ()

Desired Output I want output something like that

You can use either -

plt.scatter (-1 * x.real, -1 * x.imag, color = 'blue')

or simply -

plt.scatter (-x.real, -x.imag, color = 'blue')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM