Skip to content

Instantly share code, notes, and snippets.

@alyssaq
Created November 2, 2017 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alyssaq/90af455d02e9641bd139f15c5576ec79 to your computer and use it in GitHub Desktop.
Save alyssaq/90af455d02e9641bd139f15c5576ec79 to your computer and use it in GitHub Desktop.
Different y scales with datetime x-axis
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import datetime
t = datetime.datetime.now().date()
varr = range(10)
tarr = matplotlib.dates.date2num([t + datetime.timedelta(days=i) for i in varr])
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax1.plot(tarr, varr, 'r-')
ax2 = ax1.twinx()
ax2.plot_date(tarr, list(range(3, 13))[::-1], 'b.')
xfmt = mdates.DateFormatter('%d-%b %H:%M')
ax1.xaxis.set_major_formatter(xfmt)
fig.show()
@alyssaq
Copy link
Author

alyssaq commented Nov 2, 2017

unknown-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment