Created
August 23, 2017 16:04
-
-
Save kvedala/eb25b607d6290fdce7de9b0056269e90 to your computer and use it in GitHub Desktop.
Complex exponentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
from mpl_toolkits.axes_grid.axislines import SubplotZero | |
from matplotlib.transforms import BlendedGenericTransform | |
plt.rcParams['svg.fonttype'] = 'none' | |
A = complex(.5,.75) | |
pows = [0]*11 | |
real = [0]*11 | |
imag = [0]*11 | |
for p in range(11): | |
pows[p] = A**(p) | |
real[p] = pows[p].real | |
imag[p] = pows[p].imag | |
fig = plt.figure(figsize=[8,8]) | |
ax = SubplotZero(fig, 111) | |
fig.add_subplot(ax) | |
ax.set_aspect('equal') | |
ax.plot([0], [0], '-ok', markersize=8) | |
ax.plot(real, imag, '-ok', markersize=8) | |
ax.plot([-1,1], [0,0], 'ob', markersize=8) | |
ax.plot([0,0], [-1,1], 'or', markersize=8) | |
circ = plt.Circle(xy=(0,0), radius=1, linestyle='-.', fill=False, color='k') | |
ax.add_patch(circ) | |
arr = ax.annotate("", | |
xytext=(0,0), xycoords='data', | |
xy=(A.real, A.imag), textcoords='data', | |
arrowprops=dict(arrowstyle="-|>", linewidth=2, | |
connectionstyle="arc3"), | |
) | |
ax.plot(A.real, A.imag, 'x', color='b', markersize=15, markeredgewidth=3) | |
for p in range(11): | |
ax.text(real[p], imag[p], '$A^{%d}$' % (p), size='xx-large') | |
for direction in ["xzero", "yzero"]: | |
ax.axis[direction].set_axisline_style("-|>") | |
ax.axis[direction].set_visible(True) | |
for direction in ["left", "right", "bottom", "top"]: | |
ax.axis[direction].set_visible(False) | |
ax.text(0, 1.025, '$\Im$', transform=BlendedGenericTransform(ax.transData, ax.transAxes), ha='center', size='large') | |
ax.text(1.025, 0, '$\Re$', transform=BlendedGenericTransform(ax.transAxes, ax.transData), va='center', size='large') | |
ax.text(.75,.95, '$A=%.1f+j\,%.2f$'%(A.real,A.imag), size='large') | |
ax.xaxis.set_ticks_position('bottom') | |
ax.yaxis.set_ticks_position('left') | |
ax.set_xticks(np.linspace(-1,1,num=5)) | |
ax.set_xticklabels(['-1','','0','','1']) | |
ax.set_yticks(np.linspace(-1,1,num=5)) | |
ax.set_yticklabels(['$-j$','','0','','$j$']) | |
ax.grid(True, linestyle='--') | |
fig.savefig('ExponentielleComplexe_Puissances2.svg', bbox_inches='tight') |
Author
kvedala
commented
Aug 23, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment