Swap two curves in the Graph Editor
Quite simply swap the array_index property, which designates which component of an array property (eg location.x or location[0], has array_index == 0), of the two fcurves. 

Example below using the python console, location as an example, change to rotation_euler for Euler rotation.

&gt;&gt;&gt; action = D.actions['CubeAction']
&gt;&gt;&gt; fx = action.fcurves.find('location', index=0) # location.x
&gt;&gt;&gt; fy = action.fcurves.find('location', index=1) # location.y
&gt;&gt;&gt; fx.array_index, fy.array_index = fy.array_index, fx.array_index