2022-04-20

Positioning the axis label on polar plot / color coded legend

I'm trying to make the Distance label originate at the center of the plot and there to be a legend which describes the change in color based on the inputted change in temperature.

Here's the code:

import matplotlib.pyplot as plt
import numpy as np

theta = np.array(data["ra"])
dist_arr = np.array(data["dist"])
colors = np.log10(np.array(data["T"]))
area = np.array(data["M_V"])**2


fig = plt.figure(dpi=300)
ax = fig.add_subplot(projection='polar')
c = ax.scatter(theta, dist_arr,c=colors, s=area, cmap='hsv', alpha=0.75, label='Stars')
ax.set_title("Stars < 20 light years away", va='bottom')
ax.set_ylabel('Distance (ly)', size=12, loc='bottom')
ax.legend(loc='best', scatterpoints=1)

plt.show()

Here's the graph currently:

Polar Plot Output



No comments:

Post a Comment