Home > OS >  python | matplotlib | plt.fill_between two lines in a Circle
python | matplotlib | plt.fill_between two lines in a Circle

Time:05-11

Hey can someone help me?

I want to fill the area between the lines. I have two areas finished, but the other one, I don't know how I do that.

This is my code:

import numpy as np
import matplotlib.pyplot as plt

# Constellation:
M = 8
A = 1 # Amplitude
m = np.arange(0,M) #all information symbols m={0,1,...,M-1}
I = A*np.cos(m/M*2*np.pi)
Q = A*np.sin(m/M*2*np.pi)
constellation = I   1j*Q #reference constellation  

# Plotting the fig: 
fig,ax = plt.subplots(figsize=[10,10])

ax.plot([-1/2,0],[-1,0],'k--')
ax.plot([1/2,0],[-1,0],'k--')
ax.plot([1/2,0],[1,0],'k--')
ax.plot([-1/2,0],[1,0],'k--')

ax.plot([-1,0],[-1/2,0],'k--')
ax.plot([1,0],[1/2,0],'k--')
ax.plot([-1,0],[1/2,0],'k--')
ax.plot([1,0],[-1/2,0],'k--')

plt.fill_between([0,-1], [0,-1/2],[0,1/2],color='gray',alpha=0.5)
plt.fill_between([0,1], [0,-1/2],[0,1/2],color='gray',alpha=0.5)



circle =  plt.Circle((0,0),1,color='k',linestyle='--',fill=False)
ax.add_patch(circle)



ax.scatter(np.real(constellation),np.imag(constellation),c='c',s=20**2)


ax.set_xlabel(r'I-Axis $Real\{x\}$')
ax.set_ylabel(r'Q-Axis $Imag\{x\}$')
plt.tight_layout();

and this is my current output: enter image description here

  • Related