Python / Matplotlib pattern for backfilling a polygon field

Currently, I have the following script that generates a polar graph of azimuth / radius data. "R1" is a simple list of values ​​[azimuth, slope] obtained from a table in ArcGIS.

import matplotlib.pyplot as plt
import numpy as np 

for(a,r) in R1:
    angles.append(a)
    radius.append(90-r)
theta = np.radians(angles)
r = radius

ax = plt.subplot(111,polar=True)
ax.plot(theta, r, color='black', ls='-', linewidth=1)
ax.fill(theta,r,'0.75') ## should I use ax.fill_betweenx() ?
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)
ax.set_rmax(90)
ax.set_rmin(0)
ax.set_yticks(range(0,90,10))
yLabel=['90','','','60','','','30','','','']
ax.set_yticklabels(yLabel)
ax.grid(True)
plt.show()

This currently creates the following schedule:

enter image description here

How can I “invert” a padding so that the padding is gray and white is gray?

I tried ax.fill_betweenx (theta, 90, r, color = '0.75') and it did not work. I struggled with this for some time, but to no avail.

ANY help or suggestions are welcome!

If there is a way, I can make this clearer, please let me know in the comments.

+4
1

, , :

import matplotlib.pyplot as plt
import numpy as np
ax = plt.subplot(111, polar=True)

theta = np.linspace(0, 2*np.pi, 100)
r = 2 + np.sin(theta * 2)
ax.patch.set_facecolor('0.5')
ax.plot(theta, r, color='black', ls='-', linewidth=1)
ax.fill(theta,r,'w')
plt.show()
plt.draw() # just to be safe!
+3

Source: https://habr.com/ru/post/1542241/


All Articles