Issue
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(13, 13))
ax1 = plt.subplot( projection='polar')
ax1.set_theta_zero_location('N')
ax1.set_thetagrids(np.arange(0.0, 360.0, 25.7143))# /14
ax1.set_rgrids(np.arange(0.8,1,))
amount1 = [('89','c'),'04','76',('93','a'),'56',
'11','45','61','85',('37','b'),
'51','97','24','07']
r = 0.8
#theta = 25.7143 * range(14) # amount1:add to intersections
plt.show()
chart make in photoshop. I am a newbie with python. I am a foreigner, and my question is expressed through code and graphics
Solution
To calculate the angles for set_thetagrids
, you can use np.linspace
from 0
to 360
with 14
steps but with endpoint=False
.
The angles for the placement are in radians; np.radians(thetas)
converts them. To place the texts, you can loop through amount1
. A little circle can be positioned e.g. via ax1.scatter(x, y, ...)
with a given interior and edge color.
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(13, 13))
ax1 = plt.subplot(projection='polar')
ax1.set_theta_zero_location('N')
thetas = np.linspace(0, 360, 14, endpoint=False)
ax1.set_thetagrids(thetas)
ax1.set_rgrids([0.8, 1], [])
ax1.set_ylim(0, 1)
amount1 = [('89', 'c'), '04', '76', ('93', 'a'), '56', '11', '45', '61', '85', ('37', 'b'), '51', '97', '24', '07']
r = 0.8
for am1, theta in zip(amount1, np.radians(thetas)):
color = 'white'
if type(am1) is tuple:
color = {'a': 'turquoise', 'b': 'orchid', 'c': 'lightcoral'}[am1[1]]
am1 = am1[0]
ax1.text(theta, r, am1, color='firebrick', ha='center', va='center')
ax1.scatter(theta, r, s=500, marker='o', color=color, edgecolor='red', alpha=0.5)
plt.show()
Answered By - JohanC
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.