nipy
nipy

Reputation: 5498

Series plot - set y axis to series values

Data:

type(today_slice.Last)
pandas.core.series.Series

today_slice.Last.head(5)
Timestamp
2016-12-29 02:00:00   164.45
2016-12-29 02:03:00   164.42
2016-12-29 02:06:00   164.40
2016-12-29 02:09:00   164.41
2016-12-29 02:12:00   164.41
Name: Last, dtype: float64

Plot:

Can you please tell me why the y axis is not showing the values in format 164.42 etc as per the Series values?

today_slice.Last.plot(yticks=today_slice.Last)

enter image description here

Upvotes: 1

Views: 123

Answers (1)

Fabio Lamanna
Fabio Lamanna

Reputation: 21574

This should do the trick. You have to format the axis ticks with:

from matplotlib.ticker import FormatStrFormatter

ax = today_slice.Last.plot()
ax.yaxis.set_major_formatter(FormatStrFormatter('%.2f'))

Upvotes: 2

Related Questions