python - pandas / matplotlib: change tick label format (force plain not scientific) -
i have pandas dataframe
2 columns in below format:
df.head() column1 column2 time 1900-01-01 12:30:05.089883 19042.5 19042.8615 1900-01-01 12:30:05.210055 19042.5 19042.8615 1900-01-01 12:30:05.290165 19042.5 19042.8615 1900-01-01 12:30:05.449856 19042.5 19042.8615
i plotting columns on same matplotlib axes subplot
def plot(df): ax = df.plot(y='column1', figsize=(20, 8)) df.plot(y='column2', ax=ax) # doesn't make difference ax.ticklabel_format(style='plain', axis='y') mpl.pyplot.show() plot(df)
i'd print y-axis in plain
format - how can force stop using scientific
?
that is, y-axis goes 0
6
, , has additional label 1.9037e4
. fo 19037
19043
i've tried this, doesn't make difference:
ax.ticklabel_format(style='plain', axis='y')
from docs:
to reduce chances ticklabels overlap ticks labeled deltas fixed offset. example:
ax.plot(np.arange(2000, 2010), range(10))
will have tick of 0-9 offset of +2e3. if not desired turn off use of offset on default formatter:
ax.get_xaxis().get_major_formatter().set_useoffset(false)
set rcparam
axes.formatter.useoffset=false
turn off globally, or set different formatter.
so, can write
ax.get_yaxis().get_major_formatter().set_useoffset(false)
to turn off offset.
Comments
Post a Comment