Revision: 6920 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6920&view=rev Author: mmetz_bn Date: 2009-02-18 14:44:08 +0000 (Wed, 18 Feb 2009)
Log Message: ----------- Added scatter_hist example Added Paths: ----------- branches/v0_98_5_maint/examples/pylab_examples/scatter_hist.py Added: branches/v0_98_5_maint/examples/pylab_examples/scatter_hist.py =================================================================== --- branches/v0_98_5_maint/examples/pylab_examples/scatter_hist.py (rev 0) +++ branches/v0_98_5_maint/examples/pylab_examples/scatter_hist.py 2009-02-18 14:44:08 UTC (rev 6920) @@ -0,0 +1,49 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.ticker import NullFormatter + +# the random data +x = np.random.randn(1000) +y = np.random.randn(1000) + +nullfmt = NullFormatter() # no labels + +# definitions for the axes +left, width = 0.1, 0.65 +bottom, height = 0.1, 0.65 +bottom_h = left_h = left+width+0.02 + +rect_scatter = [left, bottom, width, height] +rect_histx = [left, bottom_h, width, 0.2] +rect_histy = [left_h, bottom, 0.2, height] + +# start with a rectangular Figure +plt.figure(1, figsize=(8,8)) + +axScatter = plt.axes(rect_scatter) +axHistx = plt.axes(rect_histx) +axHisty = plt.axes(rect_histy) + +# no labels +axHistx.xaxis.set_major_formatter(nullfmt) +axHisty.yaxis.set_major_formatter(nullfmt) + +# the scatter plot: +axScatter.scatter(x, y) + +# now determine nice limits by hand: +binwidth = 0.25 +xymax = np.max( [np.max(np.fabs(x)), np.max(np.fabs(y))] ) +lim = ( int(xymax/binwidth) + 1) * binwidth + +axScatter.set_xlim( (-lim, lim) ) +axScatter.set_ylim( (-lim, lim) ) + +bins = np.arange(-lim, lim + binwidth, binwidth) +axHistx.hist(x, bins=bins) +axHisty.hist(y, bins=bins, orientation='horizontal') + +axHistx.set_xlim( axScatter.get_xlim() ) +axHisty.set_ylim( axScatter.get_ylim() ) + +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins