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

Skip to content

Commit d8d54a8

Browse files
committed
added new ticker scheme
svn path=/trunk/matplotlib/; revision=243
1 parent b93f042 commit d8d54a8

11 files changed

Lines changed: 199 additions & 7 deletions

.matplotlibrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ axes.labelsize : 12 # fontsize of the x any y labels
103103
axes.labelcolor : k # black
104104

105105
### TICKS
106-
tick.size : 4 # tick size in points
106+
tick.major.size : 5 # major tick size in points
107+
tick.minor.size : 3 # minor tick size in points
107108
tick.color : k # color of the tick labels
108109
tick.labelsize : 10 # fontsize of the tick labels
109110

MANIFEST

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ GOALS
55
INSTALL
66
INTERACTIVE
77
KNOWN_BUGS
8+
MANIFEST
89
MANIFEST.in
910
Makefile
1011
README
@@ -176,8 +177,11 @@ examples/break.py
176177
examples/color_demo.py
177178
examples/colours.py
178179
examples/coords_demo_gtk.py
180+
examples/coords_interact.py
179181
examples/csd_demo.py
180182
examples/data_helper.py
183+
examples/date_demo1.py
184+
examples/date_demo2.py
181185
examples/dynamic_demo.py
182186
examples/dynamic_demo_wx.py
183187
examples/embedding_in_gtk.py
@@ -187,6 +191,7 @@ examples/embedding_in_wx.py
187191
examples/errorbar_demo.py
188192
examples/figtext.py
189193
examples/fill_demo.py
194+
examples/font_properties_demo.py
190195
examples/ftface_props.py
191196
examples/gdtest.py
192197
examples/histogram_demo.py
@@ -201,6 +206,7 @@ examples/line_styles.py
201206
examples/log_demo.py
202207
examples/log_test.py
203208
examples/logo.py
209+
examples/major_minor_demo1.py
204210
examples/mathtext_demo.py
205211
examples/mpl_with_glade.glade
206212
examples/mpl_with_glade.py
@@ -322,7 +328,9 @@ matplotlib/axis.py
322328
matplotlib/backend_bases.py
323329
matplotlib/cbook.py
324330
matplotlib/colors.py
331+
matplotlib/dates.py
325332
matplotlib/figure.py
333+
matplotlib/finance.py
326334
matplotlib/font_manager.py
327335
matplotlib/image.py
328336
matplotlib/legend.py
@@ -332,9 +340,13 @@ matplotlib/matlab.py
332340
matplotlib/mlab.py
333341
matplotlib/numerix.py
334342
matplotlib/patches.py
343+
matplotlib/postinstall.py
335344
matplotlib/pyparsing.py
345+
matplotlib/setup.py
346+
matplotlib/setupext.py
336347
matplotlib/table.py
337348
matplotlib/text.py
349+
matplotlib/ticker.py
338350
matplotlib/transforms.py
339351
matplotlib/windowing.py
340352
matplotlib/backends/__init__.py
@@ -350,7 +362,6 @@ matplotlib/backends/backend_tkagg.py
350362
matplotlib/backends/backend_wx.py
351363
matplotlib/backends/backend_wxagg.py
352364
matplotlib/backends/tkagg.py
353-
matplotlib/backends/ttf_font_manager.py
354365
src/_backend_agg.cpp
355366
src/_backend_agg.h
356367
src/_gtkagg.cpp

examples/date_demo1.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""
2+
Show how to make date plots in matplotlib using date tick locators and
3+
formatters. See major_minor_demo1.py for more information on
4+
controlling major and minor ticks
5+
6+
All matplotlib date plotting is done by converting date instances into
7+
seconds since the epoch, gmtime. The conversion, tick locating and
8+
formatting is done behind the scenes so this is most transparent to
9+
you. The dates module provides several converter classes that you can
10+
pass to the date plotting functions which will convert your dates as
11+
necessary. Currently epoch dates (already converted) are supported
12+
with EpochCOnverter, python2.3 datetime instances are supported with
13+
PyDatetimeConverter, and it won't be much work to add an mx.Datetime
14+
converter.
15+
16+
If you want to define your own converter, the minimum you need to do
17+
is derive a class from dates.DateConverter and implement the epoch and
18+
from_epoch methods.
19+
20+
This example requires an active internet connection since it uses
21+
yahoo finance to get the data for plotting
22+
"""
23+
24+
from matplotlib.matlab import *
25+
from matplotlib.dates import PyDatetimeConverter
26+
from matplotlib.finance import quotes_historical_yahoo
27+
from matplotlib.ticker import YearLocator, MonthLocator, DateFormatter
28+
import datetime
29+
30+
date1 = datetime.date( 1995, 1, 1 )
31+
date2 = datetime.date( 2004, 4, 12 )
32+
33+
pydates = PyDatetimeConverter()
34+
35+
years = YearLocator(1) # every year
36+
months = MonthLocator(1) # every month
37+
yearsFmt = DateFormatter('%Y')
38+
39+
40+
quotes = quotes_historical_yahoo(
41+
'INTC', date1, date2, converter=pydates)
42+
43+
dates = [q[0] for q in quotes]
44+
opens = [q[1] for q in quotes]
45+
46+
ax = subplot(111)
47+
plot_date(dates, opens, pydates)
48+
49+
ax.xaxis.set_major_locator(years)
50+
ax.xaxis.set_major_formatter(yearsFmt)
51+
ax.xaxis.set_minor_locator(months)
52+
ax.xaxis.autoscale_view()
53+
grid(True)
54+
show()

examples/date_demo2.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Show how to make date plots in matplotlib using date tick locators and
3+
formatters. See major_minor_demo1.py for more information on
4+
controlling major and minor ticks
5+
"""
6+
7+
from matplotlib.matlab import *
8+
from matplotlib.dates import PyDatetimeConverter, MONDAY, SATURDAY
9+
from matplotlib.finance import quotes_historical_yahoo
10+
from matplotlib.ticker import MonthLocator, WeekdayLocator, DateFormatter
11+
import datetime
12+
13+
date1 = datetime.date( 2003, 1, 1 )
14+
date2 = datetime.date( 2004, 4, 12 )
15+
16+
pydates = PyDatetimeConverter()
17+
18+
mondays = WeekdayLocator(SATURDAY) # every monday
19+
months = MonthLocator(1) # every month
20+
monthsFmt = DateFormatter('%b %d')
21+
22+
23+
24+
quotes = quotes_historical_yahoo(
25+
'INTC', date1, date2, converter=pydates)
26+
27+
dates = [q[0] for q in quotes]
28+
opens = [q[1] for q in quotes]
29+
30+
ax = subplot(111)
31+
plot_date(dates, opens, pydates)
32+
33+
ax.xaxis.set_major_locator(months)
34+
ax.xaxis.set_major_formatter(monthsFmt)
35+
ax.xaxis.set_minor_locator(mondays)
36+
ax.xaxis.autoscale_view()
37+
#ax.xaxis.grid(False, 'major')
38+
#ax.xaxis.grid(True, 'minor')
39+
40+
labels = ax.get_xticklabels()
41+
set(labels, 'rotation', 'vertical')
42+
grid(True)
43+
show()

examples/interactive2.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import gtk.gdk
1212

1313
import code
14-
import sys
14+
import os, sys
1515
import pango
1616

1717
import __builtin__
@@ -364,6 +364,15 @@ def key_event(widget,event):
364364
console.execute_line('matplotlib.interactive(1)')
365365
console.execute_line('from matplotlib.matlab import *')
366366

367+
368+
if len(sys.argv)>1:
369+
fname = sys.argv[1]
370+
if not os.path.exists(fname):
371+
print >> sys.stderr, '%s does not exist' % fname
372+
for line in file(fname):
373+
line = line.strip()
374+
375+
console.execute_line(line)
367376
gtk.main()
368377

369378
if __name__ == '__main__':

examples/log_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111

1212
subplot(313)
1313
loglog(t, exp(-t/10.0))
14+
grid(True)
1415
#savefig('log_demo')
1516
show()

examples/major_minor_demo1.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""
2+
Demonstrate how to use major and minor tickers.
3+
4+
The two relevant userland classes are Locators and Formatters.
5+
Locators determine where the ticks are and formatters control the
6+
formatting of ticks.
7+
8+
Minor ticks are off by default (NullLocator and NullFormatter). You
9+
can turn minor ticks on w/o labels by setting the minor locator. You
10+
can also turn labeling on for the minor ticker by setting the minor
11+
formatter
12+
13+
Make a plot with major ticks on the 10s and minor ticks on the even
14+
numbersints. Label major ticks with %d formatting but don't label
15+
minor ticks
16+
17+
The MultipleLocator ticker class is used to place ticks on multiples of
18+
some base. The FormatStrFormatter uses a string format string (eg
19+
'%d' or '%1.2f' or '%1.1f cm' ) to format the tick
20+
21+
The matlab interface grid command chnages the grid settings of the
22+
major ticks of the y and y axis together. If you want to control the
23+
grid of the minor ticks for a given axis, use for example
24+
25+
ax.xaxis.grid(True, which='minor')
26+
"""
27+
28+
from matplotlib.matlab import *
29+
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
30+
31+
majorLocator = MultipleLocator(20)
32+
majorFormatter = FormatStrFormatter('%d')
33+
minorLocator = MultipleLocator(5)
34+
35+
36+
t = arange(0.0, 100.0, 0.1)
37+
s = sin(0.1*pi*t)*exp(-t*0.01)
38+
39+
ax = subplot(111)
40+
plot(t,s)
41+
42+
ax.xaxis.set_major_locator(majorLocator)
43+
ax.xaxis.set_major_formatter(majorFormatter)
44+
45+
#for the minor ticks, use no labels; default NullFormatter
46+
ax.xaxis.set_minor_locator(minorLocator)
47+
48+
show()

examples/major_minor_demo2.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Set the major ticks on the ints and minor ticks on multiples of 0.2
3+
"""
4+
5+
from matplotlib.matlab import *
6+
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
7+
8+
majorLocator = MultipleLocator(1)
9+
majorFormatter = FormatStrFormatter('%d')
10+
minorLocator = MultipleLocator(.2)
11+
12+
13+
t = arange(0.0, 10.0, 0.01)
14+
s = sin(2*pi*t)*exp(-t*0.01)
15+
16+
ax = subplot(111)
17+
plot(t,s)
18+
19+
ax.xaxis.set_major_locator(majorLocator)
20+
ax.xaxis.set_major_formatter(majorFormatter)
21+
22+
#for the minor ticks, use no labels; default NullFormatter
23+
ax.xaxis.set_minor_locator(minorLocator)
24+
25+
show()

examples/simple_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
xlabel('time (s)')
99
ylabel('voltage (mV)')
1010
title('About as simple as it gets, folks')
11-
#grid(True)
11+
grid(True)
1212
savefig('simple_plot',dpi=300)
1313
show()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
build_image(ext_modules, packages, BUILD_IMAGE)
8686

8787
setup(name="matplotlib",
88-
version= '0.52.1b',
88+
version= '0.53a',
8989
description = "Matlab style python plotting package",
9090
author = "John D. Hunter",
9191
author_email="[email protected]",

0 commit comments

Comments
 (0)