0

enter image description hereI have graph and would like to rescale the x-axis ticks by a factor of 10. The graph is plotted by using two columns in a dataframe. Right now, the x-axis ranges from 0.5 to 1.0. I would like to multiply the ticks by a factor of 10. Thus, the x-axis shall display 5 to 10 without messing up the data or the graph.

plt.figure(dpi=150)
plt.scatter(vs['Global-Normalised Sentiment Index'], vs['Global-ERSA_Score'])
sns.despine()
plt.grid(False)
plt.xlim(0.5,1.0)
plt.ylim(10,100)
plt.show()

Thanks in advance! Any help is appreciated!!!

Matthias Gallagher
  • 475
  • 1
  • 7
  • 20
  • You can use self-defined tics. Check [this post.](https://stackoverflow.com/questions/3100985/plot-with-custom-text-for-x-axis-points) – Mig B Aug 03 '20 at 08:58
  • 1
    You could also just multiply your x values by 10 (plt.scatter(10*vs['Global....'], vs['Global...']) Edit: and set xlim to (5,10) in such case – dm2 Aug 03 '20 at 08:59

1 Answers1

1

As shown in the official docs, you can modify axis ticks to custom ones with plt.xticks(). Therefore you need to define two arrays/tuples of the same length; one for the real tic positions on your axis and another one to provide the labels you want to be plotted at this positions.

Adding the following line should solve your problem:

plt.xticks((0.5, 0.6, 0.7, 0.8, 0.9, 1.0), ("5", "6", "7", "8", "9", "10"))

Mig B
  • 637
  • 1
  • 11
  • 19