title: Adjusting the position of a matplotlib floating axis in a subplot, and reversing an axis direction
body: <p>This question leads on from a previous question I asked yesterday that got me most of the way to what I am after: 
  <a href="https://stackoverflow.com/q/52191695/">Rotate transformation on matplotlib axis in subplot</a></p>
  
  <p>I want to create a two by two array of graphs where the bottom-left is a scatter plot and the other three are histograms projecting the x, y, and x-y data from that plot. That final histogram I want to have at a 45 degree angle, and it is the positioning of that plot which I am trying to adjust.</p>
  
  <p>Currently, I have this:</p>
  
  <pre><code>from matplotlib.transforms import Affine2D
  import mpl_toolkits.axisartist.floating_axes as floating_axes
  import matplotlib.pyplot as plt
  
  def setup_axes(fig, rect, rotation, axisScale, axisLimits, doShift):
      tr_rot = Affine2D().scale(axisScale[0], axisScale[1]).rotate_deg(rotation)
  
      # This seems to do nothing
      if doShift:
          tr_trn = Affine2D().translate(-90,-5)
      else:
          tr_trn = Affine2D().translate(0,0)
  
      tr = tr_rot + tr_trn
  
      grid_helper = floating_axes.GridHelperCurveLinear(tr, extremes=axisLimits)
  
      ax = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper)
      fig.add_subplot(ax)
      aux_ax = ax.get_aux_axes(tr)
  
      return ax, aux_ax
  
  fig  = plt.figure(1, figsize=(8, 8))
  axes = []
  axisOrientation = [0, 0, 270, -45]
  axisScale = [[1,1],[6,1],[6,1],[6,1]]
  axisPosition = [223,221,224,222]
  axisLimits = [(-0.5, 4.5, -0.5, 4.5),
                (-0.5, 4.5, 0, 12),
                (-0.5, 4.5, 0, 12),
                (-3.5, 3.5, 0, 12)]
  doShift = [False, False, False, True]
  
  label_axes = []
  for i in range(0, len(axisOrientation)):
      ax, aux_ax = setup_axes(fig, axisPosition[i], axisOrientation[i], 
                              axisScale[i], axisLimits[i], doShift[i])
      axes.append(aux_ax)
      label_axes.append(ax)
  
  numPoints = 100
  x = []
  y = []
  for i in range(0,numPoints):
      x.append(np.random.rand() + i/100.0)
      y.append(np.random.rand() + i/100.0 + np.mod(i,2)*2)
  
  axes[0].plot(x,y,ls='none',marker='x')
  label_axes[0].axis["bottom"].label.set_text('Variable 1')
  label_axes[0].axis["left"].label.set_text('Variable 2')
  
  b = np.linspace(-0.5,4.5,50)
  axes[1].hist(x, bins = b)
  axes[2].hist(y, bins = b)
  b = np.linspace(-3.5,3.5,50)
  axes[3].hist(np.array(x)-np.array(y), bins=b)
  
  for i in range(1,len(label_axes)):
      for axisLoc in ['top','left','right']:
          label_axes[i].axis[axisLoc].set_visible(False)
      label_axes[i].axis['bottom'].toggle(ticklabels=False)    
  
  fig.subplots_adjust(wspace=-0.30, hspace=-0.30, left=0.00, right=0.99, top=0.99, bottom=0.0)
  plt.show()
  </code></pre>
  
  <p>Which gives:</p>
  
  <p><a href="https://i.stack.imgur.com/bxBFq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bxBFq.png" alt="enter image description here"></a></p>
  
  <p>As you can see in the code, I try to shift the position of that top-right plot with an <code>Affine2D().translate()</code> but it seems to have no effect. Does anybody know how I might move this plot so that its x-axis almost-touches the top-right corner of the bottom-left plot's axes?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I have also just noticed that the bottom-right plot is upside-down compared to how it should be. It needs to be top-bottom mirrored somehow.</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>This code before fig.subplots_adjust() will fix that:
  <code>label_axes[2].invert_yaxis()</code></p>