4

Is it possible to shift the x and y axis label numbers for example +2 ? For example i have this image created, but i want that the label numbers begin with 2:

enter image description here

My code for this was :

jacaardMatrix = 1.662887377173091485e-01    3.432835820895522305e-01    3.568320278503046006e-01
5.065963060686015651e-02    3.160270880361173984e-01    3.374888691006233121e-01
3.093987157034442520e-02    1.802120141342756221e-01    1.748178980228928259e-01


fig2=plt.figure()  
plt.title("Radius and FRC Jacaard Values for Scoring System: "+str(i))
plt.xlabel('Radius')
plt.ylabel('FRC Size')
plt.imshow(jacaardMatrix)
Varlor
  • 1,421
  • 3
  • 22
  • 46

2 Answers2

6

You can use the extent argument of imshow to set the scale of the plot. To have it scale from 2 to 5 use

plt.imshow(jacaardMatrix, extent=[2,5,2,5])

where the first two numbers denote the x range and the second two numbers the y range.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
1

I believe you can do

import mathplotlib.pyplot as p
plt.xticks(np.arange(-0.5, 3, 0.5), np.arange(2, 5.5, 0.5))

See for example this. Thanks to ImportanceOfBeingErnest for their comment.

Auden Young
  • 1,147
  • 2
  • 18
  • 39
  • This won't work since the scale is still -0.5 to 2.5. You may set the xticks **and** xticklabels instead, `plt.xticks(np.arange(-0.5, 3, 0.5), np.arange(2, 5.5, 0.5))`. – ImportanceOfBeingErnest Jul 07 '17 at 01:15