Skip to content

Commit

Permalink
added hist bin fix
Browse files Browse the repository at this point in the history
svn path=/trunk/matplotlib/; revision=1433
  • Loading branch information
jdh2358 committed Jun 9, 2005
1 parent 24be976 commit 5bb54e0
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ tick.major.size : 4 # major tick size in points
tick.minor.size : 2 # minor tick size in points
tick.major.pad : 4 # distance to major tick label in points
tick.minor.pad : 4 # distance to the minor tick label in points
tick.color : black # color of the tick labels
tick.labelsize : 10 # fontsize of the tick labels
tick.color : k # color of the tick labels
tick.labelsize : 12 # fontsize of the tick labels

### Grids
grid.color : black # grid color
Expand Down
40 changes: 40 additions & 0 deletions API_CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
API CHANGES in matplotlib-0.81.1

Sean Richards notes there was a problem in the way we created the
binning for histogram, which made the last bin underrepresented.
From his post

I see that hist uses the linspace function to create the bins and
then uses searchsorted to put the values in their correct
bin. Thats all good but I am confused over the use of linspace for
the bin creation. I wouldn't have thought that it does what is
needed, to quote the docstring it creates a "Linear spaced array
from min to max". For it to work correctly shouldn't the values in
the bins array be the same bound for each bin? (i.e. each value
should be the lower bound of a bin). To provide the correct bins
for hist would it not be something like

def bins(xmin, xmax, N):
if N==1: return xmax
dx = (xmax-xmin)/N # instead of N-1
return xmin + dx*arange(N)


This suggestion in implemented in 0.81. My test script with these
changes does not reveal any bias in the binning

from matplotlib.numerix.mlab import randn, rand, zeros, Float
from matplotlib.mlab import hist, mean

Nbins = 50
Ntests = 200
results = zeros((Ntests,Nbins), typecode=Float)
for i in range(Ntests):
print 'computing', i
x = rand(10000)
n, bins = hist(x, Nbins)
results[i] = n
print mean(results)



API CHANGES in matplotlib-0.81


Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
New entries should be added at the top

2005-06-07 Fixed a bug in texmanager.py: .aux files not being removed - DSD

2005-06-08 Added Sean Richard's hist binning fix -- see API_CHANGES - JDH

2005-06-07 Fixed a bug in texmanager.py: .aux files not being removed
- DSD

================================================================

2005-06-07 matplotlib-0.81 released

2005-06-06 Added autoscale_on prop to axes

Expand Down
20 changes: 10 additions & 10 deletions LICENSE/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LICENSE AGREEMENT FOR MATPLOTLIB 0.80
LICENSE AGREEMENT FOR MATPLOTLIB 0.81
--------------------------------------

1. This LICENSE AGREEMENT is between John D. Hunter ("JDH"), and the
Expand All @@ -9,30 +9,30 @@ documentation.
2. Subject to the terms and conditions of this License Agreement, JDH
hereby grants Licensee a nonexclusive, royalty-free, world-wide license
to reproduce, analyze, test, perform and/or display publicly, prepare
derivative works, distribute, and otherwise use matplotlib 0.80
derivative works, distribute, and otherwise use matplotlib 0.81
alone or in any derivative version, provided, however, that JDH's
License Agreement and JDH's notice of copyright, i.e., "Copyright (c)
2002-2005 John D. Hunter; All Rights Reserved" are retained in
matplotlib 0.80 alone or in any derivative version prepared by
matplotlib 0.81 alone or in any derivative version prepared by
Licensee.

3. In the event Licensee prepares a derivative work that is based on or
incorporates matplotlib 0.80 or any part thereof, and wants to
incorporates matplotlib 0.81 or any part thereof, and wants to
make the derivative work available to others as provided herein, then
Licensee hereby agrees to include in any such work a brief summary of
the changes made to matplotlib 0.80.
the changes made to matplotlib 0.81.

4. JDH is making matplotlib 0.80 available to Licensee on an "AS
4. JDH is making matplotlib 0.81 available to Licensee on an "AS
IS" basis. JDH MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, JDH MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.80
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.81
WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.

5. JDH SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB
0.80 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR
0.81 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR
LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING
MATPLOTLIB 0.80, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF
MATPLOTLIB 0.81, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF
THE POSSIBILITY THEREOF.

6. This License Agreement will automatically terminate upon a material
Expand All @@ -44,6 +44,6 @@ Licensee. This License Agreement does not grant permission to use JDH
trademarks or trade name in a trademark sense to endorse or promote
products or services of Licensee, or any third party.

8. By copying, installing or otherwise using matplotlib 0.80,
8. By copying, installing or otherwise using matplotlib 0.81,
Licensee agrees to be bound by the terms and conditions of this License
Agreement.
52 changes: 42 additions & 10 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -178,54 +178,92 @@ agg23/src/ChangeLog
agg23/src/Makefile
agg23/src/Makefile.am
agg23/src/agg_arc.cpp
agg23/src/agg_arc.o
agg23/src/agg_arrowhead.cpp
agg23/src/agg_arrowhead.o
agg23/src/agg_bezier_arc.cpp
agg23/src/agg_bezier_arc.o
agg23/src/agg_bspline.cpp
agg23/src/agg_bspline.o
agg23/src/agg_curves.cpp
agg23/src/agg_curves.o
agg23/src/agg_embedded_raster_fonts.cpp
agg23/src/agg_embedded_raster_fonts.o
agg23/src/agg_gsv_text.cpp
agg23/src/agg_gsv_text.o
agg23/src/agg_image_filters.cpp
agg23/src/agg_image_filters.o
agg23/src/agg_line_aa_basics.cpp
agg23/src/agg_line_aa_basics.o
agg23/src/agg_line_profile_aa.cpp
agg23/src/agg_line_profile_aa.o
agg23/src/agg_path_storage.cpp
agg23/src/agg_path_storage.o
agg23/src/agg_rasterizer_scanline_aa.cpp
agg23/src/agg_rasterizer_scanline_aa.o
agg23/src/agg_rounded_rect.cpp
agg23/src/agg_rounded_rect.o
agg23/src/agg_sqrt_tables.cpp
agg23/src/agg_sqrt_tables.o
agg23/src/agg_trans_affine.cpp
agg23/src/agg_trans_affine.o
agg23/src/agg_trans_double_path.cpp
agg23/src/agg_trans_double_path.o
agg23/src/agg_trans_single_path.cpp
agg23/src/agg_trans_single_path.o
agg23/src/agg_trans_warp_magnifier.cpp
agg23/src/agg_trans_warp_magnifier.o
agg23/src/agg_vcgen_bspline.cpp
agg23/src/agg_vcgen_bspline.o
agg23/src/agg_vcgen_contour.cpp
agg23/src/agg_vcgen_contour.o
agg23/src/agg_vcgen_dash.cpp
agg23/src/agg_vcgen_dash.o
agg23/src/agg_vcgen_markers_term.cpp
agg23/src/agg_vcgen_markers_term.o
agg23/src/agg_vcgen_smooth_poly1.cpp
agg23/src/agg_vcgen_smooth_poly1.o
agg23/src/agg_vcgen_stroke.cpp
agg23/src/agg_vcgen_stroke.o
agg23/src/agg_vpgen_clip_polygon.cpp
agg23/src/agg_vpgen_clip_polygon.o
agg23/src/agg_vpgen_clip_polyline.cpp
agg23/src/agg_vpgen_clip_polyline.o
agg23/src/agg_vpgen_segmentator.cpp
agg23/src/agg_vpgen_segmentator.o
agg23/src/authors
agg23/src/autogen.sh
agg23/src/configure.in
agg23/src/copying
agg23/src/install
agg23/src/libagg.a
agg23/src/news
agg23/src/readme
agg23/src/ctrl/Makefile.am
agg23/src/ctrl/agg_bezier_ctrl.cpp
agg23/src/ctrl/agg_bezier_ctrl.o
agg23/src/ctrl/agg_cbox_ctrl.cpp
agg23/src/ctrl/agg_cbox_ctrl.o
agg23/src/ctrl/agg_gamma_ctrl.cpp
agg23/src/ctrl/agg_gamma_ctrl.o
agg23/src/ctrl/agg_gamma_spline.cpp
agg23/src/ctrl/agg_gamma_spline.o
agg23/src/ctrl/agg_polygon_ctrl.cpp
agg23/src/ctrl/agg_polygon_ctrl.o
agg23/src/ctrl/agg_rbox_ctrl.cpp
agg23/src/ctrl/agg_rbox_ctrl.o
agg23/src/ctrl/agg_scale_ctrl.cpp
agg23/src/ctrl/agg_scale_ctrl.o
agg23/src/ctrl/agg_slider_ctrl.cpp
agg23/src/ctrl/agg_slider_ctrl.o
agg23/src/ctrl/agg_spline_ctrl.cpp
agg23/src/ctrl/agg_spline_ctrl.o
agg23/src/platform/Makefile.am
agg23/src/platform/AmigaOS/agg_platform_support.cpp
agg23/src/platform/BeOS/agg_platform_support.cpp
agg23/src/platform/X11/Makefile.am
agg23/src/platform/X11/agg_platform_support.cpp
agg23/src/platform/X11/agg_platform_support.o
agg23/src/platform/mac/agg_mac_pmap.cpp
agg23/src/platform/mac/agg_platform_support.cpp
agg23/src/platform/sdl/agg_platform_support.cpp
Expand Down Expand Up @@ -279,6 +317,7 @@ examples/cursor_demo.py
examples/custom_ticker1.py
examples/customize_rc.py
examples/dash_control.py
examples/dashpointlabel.py
examples/dashtick.py
examples/data_helper.py
examples/date_demo1.py
Expand Down Expand Up @@ -526,7 +565,6 @@ lib/dateutil/rrule.py
lib/dateutil/tz.py
lib/matplotlib/.cvsignore
lib/matplotlib/__init__.py
lib/matplotlib/__init__.py.~1.53.~
lib/matplotlib/_contour.py
lib/matplotlib/_image.py
lib/matplotlib/_mathtext_data.py
Expand All @@ -535,18 +573,15 @@ lib/matplotlib/_transforms.py
lib/matplotlib/afm.py
lib/matplotlib/agg.py
lib/matplotlib/artist.py
lib/matplotlib/artist.py.~1.21.~
lib/matplotlib/axes.py
lib/matplotlib/axes.py.orig
lib/matplotlib/axes.py.~1.104.~
lib/matplotlib/axis.py
lib/matplotlib/axis.py.~1.23.~
lib/matplotlib/axis.py.orig
lib/matplotlib/axis.py.rej
lib/matplotlib/backend_bases.py
lib/matplotlib/cbook.py
lib/matplotlib/cm.py
lib/matplotlib/cm.py.~1.16.~
lib/matplotlib/collections.py
lib/matplotlib/collections.py.~1.20.~
lib/matplotlib/colors.py
lib/matplotlib/contour.py
lib/matplotlib/dates.py
Expand All @@ -560,19 +595,16 @@ lib/matplotlib/mathtext.py
lib/matplotlib/mlab.py
lib/matplotlib/patches.py
lib/matplotlib/pylab.py
lib/matplotlib/pylab.py.~1.63.~
lib/matplotlib/pyparsing.py
lib/matplotlib/table.py
lib/matplotlib/texmanager.py
lib/matplotlib/text.py
lib/matplotlib/ticker.py
lib/matplotlib/ticker.py.~1.25.~
lib/matplotlib/transforms.py
lib/matplotlib/windowing.py
lib/matplotlib/backends/.cvsignore
lib/matplotlib/backends/__init__.py
lib/matplotlib/backends/backend_agg.py
lib/matplotlib/backends/backend_agg.py.~1.25.~
lib/matplotlib/backends/backend_agg2.py
lib/matplotlib/backends/backend_cairo.py
lib/matplotlib/backends/backend_fltkagg.py
Expand Down Expand Up @@ -641,7 +673,6 @@ lib/matplotlib/enthought/util/__init__.py
lib/matplotlib/enthought/util/resource.py
lib/matplotlib/numerix/.cvsignore
lib/matplotlib/numerix/__init__.py
lib/matplotlib/numerix/__init__.py.~1.2.~
lib/matplotlib/numerix/_na_imports.py
lib/matplotlib/numerix/_nc_imports.py
lib/matplotlib/numerix/fft/__init__.py
Expand Down Expand Up @@ -1265,6 +1296,7 @@ swig/agg_path_storage.i
swig/agg_rasterizer_scanline_aa.i
swig/agg_renderer_base.i
swig/agg_renderer_scanline.i
swig/agg_scanline_bin.i
swig/agg_trans_affine.i
swig/agg_typedefs.h
swig/agg_typemaps.i
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for matplotlib

PYTHON = /usr/local/bin/python2.3
PYTHON = /usr/bin/python2.4
VERSION = `${PYTHON} setup.py --version`

DISTFILES = API_CHANGES KNOWN_BUGS INSTALL README TODO license \
Expand Down
2 changes: 1 addition & 1 deletion examples/backend_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def drive(backend, python='python2.4'):
# backends = ['Agg', 'Cairo', 'GDK', 'PS', 'SVG', 'Template']
backends = ['Agg', 'PS', 'SVG', 'Template']
# backends = [ 'GTK', 'WX', 'TkAgg']
# backends = ['PS']
backends = ['Agg', 'PS']
python = 'python2.4'
for backend in backends:
print 'testing %s' % backend
Expand Down
2 changes: 1 addition & 1 deletion examples/tex_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
fontsize=16, color='r')
grid(True)
savefig('tex_demo.eps')
savefig('jdh.ps')


show()
2 changes: 1 addition & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"""
from __future__ import generators

__version__ = '0.81'
__version__ = '0.81.1'
__revision__ = '$Revision$'
__date__ = '$Date$'

Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,11 @@ def hist(y, bins=10, normed=0):
if ymin==ymax:
ymin -= 0.5
ymax += 0.5
bins = linspace(ymin, ymax, bins)

if bins==1: bins=ymax
dy = (ymax-ymin)/bins
bins = ymin + dy*arange(bins)


n = searchsorted(sort(y), bins)
n = diff(concatenate([n, [len(y)]]))
Expand Down
11 changes: 11 additions & 0 deletions lib/matplotlib/numerix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,14 @@ def _import_fail_message(module, version):
%(which)s and then re-install matplotlib. Otherwise, the following
traceback gives more details:\n""" % _dict


g = globals()
l = locals()
__import__('ma', g, l)
__import__('fft', g, l)
__import__('linear_algebra', g, l)
__import__('random_array', g, l)
__import__('mlab', g, l)

la = linear_algebra
ra = random_array
2 changes: 2 additions & 0 deletions lib/matplotlib/pylab.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@
from patches import Polygon, Rectangle, Circle, Arrow
from transforms import blend_xy_sep_transform

import numerix as nx

# catch more than an import error here, since the src could fail too,
# eg a bad pytz install. I don't want to break all of matplotlib for
# date support
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ def get_locator(self, d):

try: ld = math.log10(d)
except OverflowError:
warnings.warn('AutoLocator illegal dataInterval range %s; returning NullLocator'%d)
return NullLocator()
raise RuntimeError('AutoLocator illegal dataInterval range')


fld = math.floor(ld)
base = 10**fld
Expand Down
4 changes: 3 additions & 1 deletion setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
'win32' : ['win32_static',],
'linux2' : ['/usr/local', '/usr',],
'linux' : ['/usr/local', '/usr',],
'darwin' : ['/sw/lib/freetype219', '/usr/local', '/usr', '/sw', '/usr/X11R6'],
# Charles Moad recommends not putting in /usr/X11R6 for darwin
# because freetype in this dir is too old for mpl
'darwin' : ['/sw/lib/freetype219', '/usr/local', '/usr', '/sw'],
'freebsd4' : ['/usr/local', '/usr'],
'freebsd5' : ['/usr/local', '/usr'],
'freebsd6' : ['/usr/local', '/usr'],
Expand Down

0 comments on commit 5bb54e0

Please sign in to comment.