The y-axis values are in thousands and the desired output would be to show the numbers as strings with commas indicating thousands, e.g. 3,000
instead of 3000
. But when reading it in the graph for matplotlib
and seaborn
, they are already in integer values, i.e.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_theme(style="darkgrid")
plt.ticklabel_format(style='plain')
xp_needed = [(41, 6000), (42, 7000), (43, 9000), (44, 11000),
(45, 13000), (46, 15500), (47, 18000), (48, 21000), (49, 25000), (50, 30000)]
df_xp = pd.DataFrame(xp_needed, columns=['x', 'y'])
ax = sns.lineplot(data=df_xp, x="x", y="y")
ax.set_xlim(40, 51)
plt.show()
[out]:
There's this solution to change the integers to strings with format
, How to convert an integer to a comma separated string but I couldn't figure out how to use that format in matplotlib for the axis labels.