So those number labels are actually the tickmarks on the radius axis. i.e. these are the distance from the barycentre in AU, not planets.
As for setting the figure size, matplotlib doesn’t work with pixel sizes, rather it uses a physical size and a DPI but you can always calculate a pixel size using the DPI:
import matplotlib.pyplot as plt
from astropy.time import Time
from sunpy.coordinates import get_body_heliographic_stonyhurst
obstime = Time('1999-10-24T18:56:00.000')
planet_list = ['sun', 'earth', 'jupiter']
planet_coord = [get_body_heliographic_stonyhurst(
this_planet, time=obstime) for this_planet in planet_list]
pixel_size = [1000,1000]
fig = plt.figure()
dpi = fig.get_dpi()
fig.set_size_inches(pixel_size[0]/dpi, pixel_size[1]/dpi)
ax = fig.add_subplot(projection='polar')
for this_planet, this_coord in zip(planet_list, planet_coord):
ax.plot(this_coord.lon.to('rad'), this_coord.radius, 'o', label=this_planet)
ax.legend()
plt.show()
Thank you alasdairwilson. The finalized Code that plots the position of the planets on a specific date and time, and render the output image in terms of dpi is:
import matplotlib.pyplot as plt
from astropy.time import Time
from sunpy.coordinates import get_body_heliographic_stonyhurst
obstime = Time('1999-10-24T18:56:00.000')
planet_list = ['sun', 'earth', 'jupiter']
planet_coord = [get_body_heliographic_stonyhurst(
this_planet, time=obstime) for this_planet in planet_list]
fig = plt.figure()
fig.set_dpi(300)
ax = fig.add_subplot(projection='polar')
for this_planet, this_coord in zip(planet_list, planet_coord):
ax.plot(this_coord.lon.to('rad'), this_coord.radius, 'o', label=this_planet)
ax.legend()
plt.show()
But still i couldn’t understand how to retrieve the position r and the longitude λ of Sun, Earth and Jupiter in the aforementioned Code. Since these are already plotted means it is calculated. I need help.
In your code, the SkyCoord object for the Sun is planet_coord[0], for the Earth is planet_coord[1], and for Jupiter is planet_coord[2]. Then, for example, “position r” of Jupiter is:
Since you are using Stonyhurst heliographic coordinates, the Sun is at zero radius and zero longitude by definition, and the Earth is at zero longitude also by definition.