# Plotting Galactic Longitude from 180 to -180

I made a scatter plot in Python that looks like this:

However, I want galactic longitude, l, to be plotted from 180 to -180 like these graphs from Iorio and Belokurov (2019):

Here is the code for my plot:

sns.set_style("ticks")
sns.set_context("poster")
%matplotlib inline
from matplotlib import pyplot as plt

fig = plt.figure(figsize=(8,5))

ax.scatter(rrl_pm.l, rrl_pm.b, s=1, color='black', alpha=0.1)

ax.set_xlim(0, 360)
ax.set_ylim(-90., 90.)

ax.set_xlabel("l [deg]")
ax.set_ylabel("b [deg]")
textstr = 'N = ' + str(len(rrl_pm.l))
props = dict(boxstyle='round', facecolor='white', alpha=0.5)
ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=16,
verticalalignment='top', bbox=props)
plt.title("Scatter Plot of Cleaned Sample of RRLs in Sgr dSph with Spatial AND PM Cuts", fontsize = 16)
plt.savefig("SP-Clean-Spatial-PM.png", dpi = 1000)
plt.show()


If I simply change the xlim to run from 180 to -180 degrees the following graph is produced:

So essentially it only covers half the sky. Why exactly is this the case and what transformations do I need to apply to the galactic longitude for the 2nd plot to "wrap around" and display both sides?

Assuming

x, y = rrl_pm.l, rrl_pm.b


The transformation you want is

xx = [(q+180)%360 - 180 for q in x]


Add 180, do modulo 360, then subtract 180.

ax.set_xlim(180, -180)


import matplotlib.pyplot as plt

x = (0, 10, 20, 40, 80, 160, 200, 280, 320, 340, 350)
y = (0, 10, 20, 30, 40, 50,  -50,  -40, -30, -20, -10)

fig = plt.figure(figsize=(8,5))

ax.scatter(x, y)

ax.set_xlim(0, 360)
ax.set_ylim(-90., 90.)

plt.title('Old', fontsize=18)

plt.show()

xx = [(q+180)%360 - 180 for q in x]  # DO THIS!

fig = plt.figure(figsize=(8,5))