Reputation: 28659
I have a pandas dataframe
with 2 columns in the 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 am plotting the columns on the same matplotlib axes subplot
def plot(df):
ax = df.plot(y='column1', figsize=(20, 8))
df.plot(y='column2', ax=ax)
# this doesn't make a difference
ax.ticklabel_format(style='plain', axis='y')
mpl.pyplot.show()
plot(df)
I'd like to print the y-axis in plain
format - how can I force it to stop using scientific
?
That is, the y-axis goes from 0
to 6
, and has an additional label 1.9037e4
. I would like it to fo from 19037
to 19043
I've tried this, but it doesn't make a difference:
ax.ticklabel_format(style='plain', axis='y')
Upvotes: 2
Views: 3169
Reputation: 12693
From the docs:
To reduce the chances that the ticklabels overlap the ticks are labeled as deltas from a fixed offset. For example:
ax.plot(np.arange(2000, 2010), range(10))
will have tick of 0-9 with an offset of +2e3. If this is not desired turn off the use of the offset on the default formatter:
ax.get_xaxis().get_major_formatter().set_useOffset(False)
set the rcParam
axes.formatter.useoffset=False
to turn it off globally, or set a different formatter.
So, you can write
ax.get_yaxis().get_major_formatter().set_useOffset(False)
to turn off the offset.
Upvotes: 3