title: Custom ticks for seaborn heatmap
body: <p>I have some <a href="https://1drv.ms/u/s!Ap0up1KFhZOughZ3dx9rwq-9yiF9" rel="nofollow noreferrer">data</a> that I would like to plot as a heatmap, it is essentially a 50x50 numpy array. As a result the heatmap axis labels range from 0 to 50, but actually I want the axis labels to go from -114 to 114 since this is the range of the data. When I set the tick labels however, they end up being bunched up on the axes (see image). </p>
  
  <p>When I put in the lines</p>
  
  <pre><code>ax.set_xticks(ticks)
  ax.set_yticks(ticks)
  </code></pre>
  
  <p>The heatmap ends up getting scaled (see image).</p>
  
  <p>I have put in my code and some sample data, maybe someone can spot what I have done wrong.</p>
  
  <pre><code>import sys
  import numpy as np
  import pandas as pd
  import matplotlib
  import matplotlib.pyplot as plt
  import os
  import cv2 as cv
  import seaborn as sns;
  
  filepath = sys.argv[1]
  drive, path_and_file = os.path.splitdrive(filepath)
  path, file = os.path.split(path_and_file)
  
  line_width = 3
  
  font = {'family' : 'sans',
          'weight' : 'normal',
          'size'   : 18}
  matplotlib.rc('font', **font)
  
  bagnames = ["hex_events_only.bag"]
  groundtruth = [-92, 0]
  noise_levels = ["-1.000000"]
  rewards = ["sos"]
  
  gt_angle = np.arctan2(groundtruth[0], groundtruth[1])
  gt_mag = np.linalg.norm(groundtruth, axis=0)
  print(gt_angle, gt_mag)
  
  for bagname in bagnames:
      print "==========", bagname, "=========="
      for reward in rewards:
          print "      ---", reward, "---       "
          for noise_level in noise_levels:
                  filename = filepath + "data_field_" + bagname + "_" + reward + "_" + noise_level
                  print filename
                  n_samples = (pd.read_csv(filename, delimiter="\t", skiprows=1, names=["vx", "vy", "measure"])).values
  
                  x = n_samples[:, 0]
                  y = n_samples[:, 1]
                  z = n_samples[:, 2]
  
                  yrange = int(np.ptp(x))
                  xrange = int(np.ptp(y))
  
                  x_values = np.unique(x).size
                  y_values = np.unique(y).size
  
                  num_ticks = 10
                  ticks = np.linspace(int(-yrange/2.), int(yrange/2.), num_ticks, dtype=np.int)
  
                  img = np.reshape(z, (x_values, y_values))
                  img = img.T
                  img = cv.resize(img, (yrange, xrange))
  
                  savename = filepath + "hmap_" + bagname + "_" + reward + "_" + noise_level
  
                  fig, ax = plt.subplots()
  
                  img = cv.GaussianBlur(img, (5, 5), 0)
                  ax = sns.heatmap(img, cmap='viridis', yticklabels=ticks, xticklabels=ticks)
  
                  # ax.set_xticks(ticks)
                  # ax.set_yticks(ticks)
  
                  # ax.axvline(groundtruth[0], linestyle='--', c='r', linewidth=line_width)
                  # ax.axhline(groundtruth[1], linestyle='--', c='r', linewidth=line_width)
                  plt.show()
                  fig.savefig(savename + ".png", transparent=True, bbox_inches='tight', pad_inches=0)
                  plt.close()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/itPL1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/itPL1.png" alt="Axis ticks all bunched up"></a></p>
  
  <p><a href="https://i.stack.imgur.com/jhLqE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jhLqE.png" alt="Weird scaling issue"></a></p>
  
  <p><a href="https://1drv.ms/u/s!Ap0up1KFhZOughZ3dx9rwq-9yiF9" rel="nofollow noreferrer">https://1drv.ms/u/s!Ap0up1KFhZOughZ3dx9rwq-9yiF9</a></p>