0

How to use commas to separate thousands for numbers with five or more digits in the plot picture. e.g., "10000" should be "10,000"

Please here is the python code

import matplotlib.pyplot as plt

E = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

m = [383, 2428, 6172, 10895, 17148, 23316, 30829, 36641, 44228, 54342]

n = [216, 881, 2040, 3811, 6101, 8363, 12158, 15833, 19538, 23956]


plt.plot(E, m, 'g', label = "proposed", linestyle="--")
plt.plot(E, n, 'r', label = "baseline", linestyle=":")


plt.xlabel('X')
plt.ylabel('Y')
plt.legend()
plt.show()
Elvissmog
  • 25
  • 4
  • Use `set_major_formatter` to provide a formatter (first linked duplicate), and define that formatter using the "format mini-language" built-in to Python's strings (second linked duplicate, see also the corresponding [documentation](https://docs.python.org/3/library/string.html#format-specification-mini-language)). Some answers at the first duplicate already show examples that include using commas for thousands separators. – Karl Knechtel Jan 17 '23 at 14:38

0 Answers0