Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 704ff2f

Browse files
committed
added coords formatters
svn path=/trunk/matplotlib/; revision=537
1 parent 5a0ff9a commit 704ff2f

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ New entries should be added at the top
22

33
==============================================================
44

5+
2004-09-17 Added coords formatter attributes. These must be callable,
6+
and return a string for the x or y data. These will be used
7+
to format the x and y data for the coords box. Default is
8+
the axis major formatter. Eg
9+
10+
# format the coords message box
11+
def price(x): return '$%1.2f'%x
12+
ax.format_xdata = DateFormatter('%Y-%m-%d')
13+
ax.format_ydata = price
14+
15+
516
2004-09-17 Total rewrite of dates handling to use python datetime with
617
num2date, date2num and drange. pytz for timezone handling,
718
dateutils for spohisticated ticking. date ranges from

TODO

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ ZeroDivisionError: SeparableTransformation::eval_scalars yin interval is zero; c
577577

578578
-- colorbar for dynamic images.
579579

580-
-- Finish the coords notification for all backends
580+
-- Finish the coords notification for all backends - allow custom
581+
formatters for toolbar
581582

582-
-- ro an rrulewrapper demo
583+
-- DONE an rrulewrapper demo

examples/date_demo1.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
months = MonthLocator() # every month
2626
yearsFmt = DateFormatter('%Y')
2727

28-
2928
quotes = quotes_historical_yahoo(
3029
'INTC', date1, date2)
3130
if not quotes:
@@ -37,9 +36,16 @@
3736
ax = subplot(111)
3837
plot_date(dates, opens)
3938

39+
# format the ticks
4040
ax.xaxis.set_major_locator(years)
4141
ax.xaxis.set_major_formatter(yearsFmt)
4242
ax.xaxis.set_minor_locator(months)
4343
ax.autoscale_view()
44+
45+
# format the coords message box
46+
def price(x): return '$%1.2f'%x
47+
ax.format_xdata = DateFormatter('%Y-%m-%d')
48+
ax.format_ydata = price
49+
4450
grid(True)
4551
show()

examples/date_demo2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
formatters. See major_minor_demo1.py for more information on
55
controlling major and minor ticks
66
"""
7-
7+
import datetime
88
from matplotlib.matlab import *
99
from matplotlib.dates import MONDAY, SATURDAY
1010
from matplotlib.finance import quotes_historical_yahoo
@@ -16,7 +16,7 @@
1616

1717
mondays = WeekdayLocator(MONDAY) # every monday
1818
months = MonthLocator(range(1,13), bymonthday=1) # every month
19-
monthsFmt = DateFormatter('%b %d')
19+
monthsFmt = DateFormatter('%b %d')
2020

2121

2222
quotes = quotes_historical_yahoo('INTC', date1, date2)

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
except ImportError:
9999
packages.append('dateutil')
100100

101+
packages.append('dateutil')
102+
101103
try: import pytz
102104
except ImportError:
103105
packages.append('pytz')

0 commit comments

Comments
 (0)