1

I am plotting some columns of a csv using Pandas/Matplotlib. The index column is the time in seconds (which has very high number).
For example:

401287629.8
401287630.8
401287631.7
401287632.8
401287633.8
401287634.8

I need this to be printed as my xticklabel when i plot. But it is changing the number format as shown below:

fig

plt.figure()
ax = dfPlot.plot()
legend = ax.legend(loc='center left', bbox_to_anchor=(1,0.5))
labels = ax.get_xticklabels()
for label in labels:
    label.set_rotation(45)
    label.set_fontsize(10)

I couldn't find a way for the xticklabel to print the exact value rather than shortened version of it.

2

2 Answers 2

2

This is essentially the same problem as How to remove relative shift in matplotlib axis

The solution is to tell the formatter to not use an offset

ax.get_xaxis().get_major_formatter().set_useOffset(False)

Also related:

Sign up to request clarification or add additional context in comments.

Comments

0

If it's not rude of me to point out, you're asking for a great deal of precision from a single chart. Your sample data shows a six-second difference over two times that are both over twelve and a half-years long.

You have to cut your cloth to your measure on this one. If you want to keep the years, you can't keep the seconds. If you want to keep the seconds, you can't have the years.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.