-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deleted "Our Favorite Recipes" section and moved the examples. #18323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,17 +14,16 @@ | |
provides the converter functions `.date2num` and `.num2date`, which convert | ||
`datetime.datetime` and `numpy.datetime64` objects to and from Matplotlib's | ||
internal representation. | ||
|
||
An alternative way of displaying dates can be seen at | ||
:doc:`/gallery/ticks_and_spines/date_concise_formatter`. | ||
""" | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import matplotlib.dates as mdates | ||
import matplotlib.cbook as cbook | ||
|
||
years = mdates.YearLocator() # every year | ||
months = mdates.MonthLocator() # every month | ||
years_fmt = mdates.DateFormatter('%Y') | ||
|
||
# Load a numpy structured array from yahoo csv data with fields date, open, | ||
# close, volume, adj_close from the mpl-data/example directory. This array | ||
# stores the date as an np.datetime64 with a day unit ('D') in the 'date' | ||
|
@@ -34,18 +33,24 @@ | |
fig, ax = plt.subplots() | ||
ax.plot('date', 'adj_close', data=data) | ||
|
||
# format the ticks | ||
ax.xaxis.set_major_locator(years) | ||
ax.xaxis.set_major_formatter(years_fmt) | ||
ax.xaxis.set_minor_locator(months) | ||
# Major ticks every 6 months | ||
fmt_half_year = mdates.MonthLocator(interval=6) | ||
ax.xaxis.set_major_locator(fmt_half_year) | ||
|
||
# Minor ticks every month | ||
fmt_month = mdates.MonthLocator() | ||
ax.xaxis.set_minor_locator(fmt_month) | ||
|
||
# Text in the x axis will be displayed in 'YYYY-mm' format | ||
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m')) | ||
|
||
# round to nearest years. | ||
# Round to nearest years. | ||
datemin = np.datetime64(data['date'][0], 'Y') | ||
datemax = np.datetime64(data['date'][-1], 'Y') + np.timedelta64(1, 'Y') | ||
ax.set_xlim(datemin, datemax) | ||
|
||
# format the coords message box | ||
ax.format_xdata = mdates.DateFormatter('%Y-%m-%d') | ||
# Format the coords message box | ||
ax.format_xdata = mdates.DateFormatter('%Y-%m') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Often when you are dragging the cursor around, you want to know exactly where something is. So why drop the day here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll merge despite this - its not that important |
||
ax.format_ydata = lambda x: '$%1.2f' % x # format the price. | ||
ax.grid(True) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.