|
From: <jd...@us...> - 2008-09-13 17:06:56
|
Revision: 6091
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6091&view=rev
Author: jdh2358
Date: 2008-09-13 17:06:53 +0000 (Sat, 13 Sep 2008)
Log Message:
-----------
added a couple of font examples
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/font_family_rc.py
trunk/matplotlib/examples/pylab_examples/font_file.py
Added: trunk/matplotlib/examples/pylab_examples/font_family_rc.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/font_family_rc.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/font_family_rc.py 2008-09-13 17:06:53 UTC (rev 6091)
@@ -0,0 +1,29 @@
+"""
+You can explicitly set which font family is picked up for a given font
+style (eg 'serif', 'sans-serif', or 'monospace').
+
+In the example below, we only allow one font family (Tahoma) for the
+san-serif font style. You the default family with the font.family rc
+param, eg::
+
+ rcParams['font.family'] = 'sans-serif'
+
+and for the font.family you set a list of font styles to try to find
+in order::
+
+ rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans', 'Lucida Grande', 'Verdana']
+
+
+"""
+from matplotlib import rcParams
+rcParams['font.family'] = 'sans-serif'
+rcParams['font.sans-serif'] = ['Tahoma']
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot([1,2,3], label='test')
+
+ax.legend()
+plt.show()
+
Added: trunk/matplotlib/examples/pylab_examples/font_file.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/font_file.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/font_file.py 2008-09-13 17:06:53 UTC (rev 6091)
@@ -0,0 +1,18 @@
+"""
+Although it is usually not a good idea to explicitly point to a single
+ttf file for a font instance, you can do so using the
+font_manager.FontProperties fname argument (for a more flexible
+solution, see the font_fmaily_rc.py and fonts_demo.py examples).
+"""
+import matplotlib.font_manager as fm
+
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot([1,2,3])
+
+prop = fm.FontProperties(fname='/Library/Fonts/Tahoma.ttf')
+ax.set_title('this is a special font', fontproperties=prop)
+plt.show()
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-10-16 19:19:32
|
Revision: 6227
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6227&view=rev
Author: mdboom
Date: 2008-10-16 19:19:24 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
Fix encoding in these files. unicode_demo.py was in latin-1, though the coding marker said utf-8 (someone's editor didn't listen... ;) tex_unicode_demo.py was converted to utf-8 to be Sphinx compatible.
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/tex_unicode_demo.py
trunk/matplotlib/examples/pylab_examples/unicode_demo.py
Modified: trunk/matplotlib/examples/pylab_examples/tex_unicode_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/tex_unicode_demo.py 2008-10-16 19:00:21 UTC (rev 6226)
+++ trunk/matplotlib/examples/pylab_examples/tex_unicode_demo.py 2008-10-16 19:19:24 UTC (rev 6227)
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# -*- coding: latin-1 -*-
+# -*- coding: utf-8 -*-
"""
This demo is tex_demo.py modified to have unicode. See that file for
more information.
@@ -18,7 +18,7 @@
plot(t, s)
xlabel(r'\textbf{time (s)}')
-ylabel(unicode(r'\textit{Velocity (\xB0/sec)}','latin-1'),fontsize=16)
+ylabel(unicode(r'\textit{Velocity (°/sec)}','latin-1'),fontsize=16)
title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
fontsize=16, color='r')
grid(True)
Modified: trunk/matplotlib/examples/pylab_examples/unicode_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/unicode_demo.py 2008-10-16 19:00:21 UTC (rev 6226)
+++ trunk/matplotlib/examples/pylab_examples/unicode_demo.py 2008-10-16 19:19:24 UTC (rev 6227)
@@ -3,10 +3,10 @@
from pylab import *
plot([1,2,4])
-title( unicode('D\xE9velopp\xE9s et fabriqu\xE9s', 'latin-1') )
-xlabel( unicode("r\xE9activit\xE9 nous permettent d'\xEAtre s\xE9lectionn\xE9s et adopt\xE9s", 'latin-1') )
+title( unicode('Développés et fabriqués', 'latin-1') )
+xlabel( unicode("réactivité nous permettent d'être sélectionnés et adoptés", 'latin-1') )
ylabel( unicode('Andr\xc3\xa9 was here!', 'utf-8') )
-text( 0.5, 2.5, unicode('Institut f\xFCr Festk\xF6rperphysik', 'latin-1'), rotation=45)
+text( 0.5, 2.5, unicode('Institut für Festkörperphysik', 'latin-1'), rotation=45)
text( 1, 1.5, u'AVA (check kerning)')
savefig('test')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-03-18 15:22:44
|
Revision: 6988
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6988&view=rev
Author: jdh2358
Date: 2009-03-18 15:22:41 +0000 (Wed, 18 Mar 2009)
Log Message:
-----------
updated finance_work2.py demo
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/finance_work2.py
trunk/matplotlib/examples/pylab_examples/legend_demo3.py
Modified: trunk/matplotlib/examples/pylab_examples/finance_work2.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/finance_work2.py 2009-03-18 07:39:43 UTC (rev 6987)
+++ trunk/matplotlib/examples/pylab_examples/finance_work2.py 2009-03-18 15:22:41 UTC (rev 6988)
@@ -1,278 +1,221 @@
-"""
-You need a additional files to run this example. Save the following
-in the same dir as this file
+## Plot the stock price with some technical indicators
+## Example usage::
+## python stocks2.py --ticker=GE --startdate=2003
+##
+import datetime, os, urllib, optparse
+import numpy as np
+import dateutil.parser
+import matplotlib.colors as colors
+import matplotlib.finance as finance
+import matplotlib.dates as mdates
+import matplotlib.ticker as mticker
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+import matplotlib.font_manager as font_manager
- http://matplotlib.sourceforge.net/screenshots/helpers.py
+today = datetime.date.today()
- http://matplotlib.sourceforge.net/screenshots/msft_nasdaq_d.csv
+optionparser = optparse.OptionParser()
- http://matplotlib.sourceforge.net/screenshots/__init__.py
+optionparser.add_option('-t', '--ticker',
+ dest='ticker',
+ help='a stock market ticker',
+ default='SPY')
-"""
+optionparser.add_option('-s', '--startdate',
+ dest='startdate',
+ help='the start date',
+ default=(today-datetime.timedelta(days=365*2)).strftime('%Y-%m-%d'))
-import time, os, sys, datetime
+optionparser.add_option('-e', '--enddate',
+ dest='enddate',
+ help='the end date',
+ default=today.strftime('%Y-%m-%d'))
-from matplotlib import rcParams
-from matplotlib.ticker import IndexLocator, FuncFormatter, NullFormatter, MultipleLocator
-from matplotlib.dates import IndexDateFormatter, date2num
-from matplotlib.finance import candlestick2, plot_day_summary2, \
- volume_overlay, index_bar
-from pylab import *
-rcParams['timezone'] = 'US/Eastern'
-rc('grid', color='0.75', linestyle='-', linewidth=0.5)
+(commandoptions, commandargs) = optionparser.parse_args()
-def ema(s, n):
- """
- returns an n period exponential moving average for
- the time series s
- s is a list ordered from oldest (index 0) to most recent (index
- -1) n is an integer
+startdate = dateutil.parser.parse(commandoptions.startdate)
+enddate = dateutil.parser.parse(commandoptions.enddate)
+ticker = commandoptions.ticker
- returns a numeric array of the exponential moving average
- """
- s = array(s)
- ema = []
- j = 1
- #get n sma first and calculate the next n period ema
- sma = sum(s[:n]) / n
- multiplier = 2 / float(1 + n)
- ema.append(sma)
- #EMA(current) = ( (Price(current) - EMA(prev) ) xMultiplier) + EMA(prev)
- ema.append(( (s[n] - sma) * multiplier) + sma)
- #now calculate the rest of the values
- for i in s[n+1:]:
- tmp = ( (i - ema[j]) * multiplier) + ema[j]
- j = j + 1
- ema.append(tmp)
- return ema
-def movavg(s, n):
- """
- returns an n period moving average for the time series s
+fh = finance.fetch_historical_yahoo(ticker, startdate, enddate)
+# a numpy record array with fields: date, open, high, low, close, volume, adj_close)
- s is a list ordered from oldest (index 0) to most recent (index -1)
- n is an integer
+r = mlab.csv2rec(fh); fh.close()
+r.sort()
- returns a numeric array of the moving average
- See also ema in this module for the exponential moving average.
+def moving_average(x, n, type='simple'):
"""
- s = array(s)
- c = cumsum(s)
- return (c[n-1:] - c[:-n+1]) / float(n-1)
+ compute an n period moving average.
-def fill_over(ax, x, y, val, color, over=True):
+ type is 'simple' | 'exponential'
+
"""
- Plot filled x,y for all y over val
- if over = False, fill all areas < val
- """
- ybase = asarray(y)-val
- crossings = nonzero(less(ybase[:-1] * ybase[1:],0))
+ x = np.asarray(x)
+ if type=='simple':
+ weights = np.ones(n)
+ else:
+ weights = np.exp(np.linspace(-1., 0., n))
- if ybase[0]>=0: fillon = over
- else: fillon = not over
+ weights /= weights.sum()
+ a = np.convolve(x, weights, mode='full')[:len(x)]
+ a[:n] = a[n]
+ return a
- indLast = 0
- for ind in crossings:
- if fillon:
- thisX = x[indLast:ind+1]
- thisY = y[indLast:ind+1]
- thisY[0] = val
- thisY[-1] = val
- ax.fill(thisX, thisY, facecolor=color)
- fillon = not fillon
- indLast = ind
+def relative_strength(prices, n=14):
+ """
+ compute the n period relative strength indicator
+ http://stockcharts.com/school/doku.php?id=chart_school:glossary_r#relativestrengthindex
+ http://www.investopedia.com/terms/r/rsi.asp
+ """
+ deltas = np.diff(prices)
+ seed = deltas[:n+1]
+ up = seed[seed>=0].sum()/n
+ down = -seed[seed<0].sum()/n
+ rs = up/down
+ rsi = np.zeros_like(r.adj_close)
+ rsi[:n] = 100. - 100./(1.+rs)
-def random_signal(N, tau):
- 'generate a length N random signal with time constant tau'
- t = arange(float(N))
- filter = exp(-t/tau)
- return convolve( randn(N), filter, mode=2)[:len(t)]
+ for i in range(n, len(prices)):
+ delta = deltas[i-1] # cause the diff is 1 shorter
+ if delta>0:
+ upval = delta
+ downval = 0.
+ else:
+ upval = 0.
+ downval = -delta
-# load a numpy record array from yahoo csv data with fields date,
-# open, close, volume, adj_close from the mpl-data/example directory.
-# The record array stores python datetime.date as an object array in
-# the date column
-datafile = matplotlib.get_example_data('goog.npy')
-r = np.load(datafile).view(np.recarray)
-r = r[-250:]
+ up = (up*(n-1) + upval)/n
+ down = (down*(n-1) + downval)/n
-N = len(r)
+ rs = up/down
+ rsi[i] = 100. - 100./(1.+rs)
-vind = np.arange(N)
+ return rsi
-figBG = 'w' # the figure background color
-axesBG = '#f6f6f6' # the axies background color
-textsize = 8 # size for axes text
-
-# the demo data are intc from (2003, 9, 1) to (2004, 4, 12 ) with
-# dates as epoch; I saved these to a file for ease of debugginh
-ticker = 'MSFT'
-
-
-figure(1, facecolor=figBG)
-
-def get_locator():
+def moving_average_convergence(x, nslow=26, nfast=12):
"""
- the axes cannot share the same locator, so this is a helper
- function to generate locators that have identical functionality
+ compute the MACD (Moving Average Convergence/Divergence) using a fast and slow exponential moving avg'
+ return value is emaslow, emafast, macd which are len(x) arrays
"""
+ emaslow = moving_average(x, nslow, type='exponential')
+ emafast = moving_average(x, nfast, type='exponential')
+ return emaslow, emafast, emafast - emaslow
- return IndexLocator(10, 1)
+plt.rc('axes', grid=True)
+plt.rc('grid', color='0.75', linestyle='-', linewidth=0.5)
-formatter = IndexDateFormatter(date2num(r.date), '%b %d %y')
-
-nullfmt = NullFormatter() # no labels
-
-def fmt_vol(x,pos):
- if pos>3: return '' # only label the first 3 ticks
- return '%dM' % int(x*1e-6)
-
-volumeFmt = FuncFormatter(fmt_vol)
-
+textsize = 9
left, width = 0.1, 0.8
rect1 = [left, 0.7, width, 0.2]
rect2 = [left, 0.3, width, 0.4]
rect3 = [left, 0.1, width, 0.2]
-axUpper = axes(rect1, axisbg=axesBG) #left, bottom, width, height
-axMiddle = axes(rect2, axisbg=axesBG, sharex=axUpper)
-axMiddleVol = axMiddle.twinx()
-axLower = axes(rect3, axisbg=axesBG, sharex=axUpper)
-axUpper.xaxis.set_major_locator( get_locator() )
-axUpper.xaxis.set_major_formatter(nullfmt)
-axUpper.grid(True)
+fig = plt.figure(facecolor='white')
+axescolor = '#f6f6f6' # the axies background color
-# set up two scales on middle axes with left and right ticks
-axMiddle.yaxis.tick_left()
-axMiddle.xaxis.set_major_formatter(nullfmt)
+ax1 = fig.add_axes(rect1, axisbg=axescolor) #left, bottom, width, height
+ax2 = fig.add_axes(rect2, axisbg=axescolor, sharex=ax1)
+ax2t = ax2.twinx()
+ax3 = fig.add_axes(rect3, axisbg=axescolor, sharex=ax1)
-axMiddleVol.yaxis.set_major_formatter(volumeFmt)
-axMiddle.grid(True)
+### plot the relative strength indicator
+prices = r.adj_close
+rsi = relative_strength(prices)
+fillcolor = 'darkgoldenrod'
-axLower.xaxis.set_major_locator( get_locator() )
-axLower.xaxis.set_major_formatter( formatter )
-axLower.grid(True)
+ax1.plot(r.date, rsi, color=fillcolor)
+ax1.axhline(70, color=fillcolor)
+ax1.axhline(30, color=fillcolor)
+ax1.fill_between(r.date, rsi, 70, facecolor=fillcolor, where=(rsi>=70))
+ax1.fill_between(r.date, rsi, 30, facecolor=fillcolor, where=(rsi<=30))
+ax1.text(0.6, 0.9, '>70 = overbought', va='top', transform=ax1.transAxes, fontsize=textsize)
+ax1.text(0.6, 0.1, '<30 = oversold', transform=ax1.transAxes, fontsize=textsize)
+ax1.set_ylim(0, 100)
+ax1.set_yticks([30,70])
+ax1.text(0.025, 0.95, 'RSI (14)', va='top', transform=ax1.transAxes, fontsize=textsize)
+ax1.set_title('%s daily'%ticker)
-if 1: ############### Upper axes #################
+### plot the price and volume data
+deltas = np.zeros_like(prices)
+deltas[1:] = np.diff(prices)
+up = deltas>0
+ax2.vlines(r.date[up], r.low[up], r.high[up], color='black', label='_nolegend_')
+ax2.vlines(r.date[~up], r.low[~up], r.high[~up], color='black', label='_nolegend_')
+ma20 = moving_average(prices, 20, type='simple')
+ma200 = moving_average(prices, 200, type='simple')
- # make up a pseudo signal
- purple = '#660033'
- s = random_signal(N, tau=20)
- thresh = 4
- axUpper.plot(s, color=purple)
- # upper horiz line
+linema20, = ax2.plot(r.date, ma20, color='blue', lw=2, label='MA (20)')
+linema200, = ax2.plot(r.date, ma200, color='red', lw=2, label='MA (200)')
+last = r[-1]
+s = '%s O:%1.2f H:%1.2f L:%1.2f C:%1.2f, V:%1.1fM Chg:%+1.2f' % (
+ today.strftime('%d-%b-%Y'),
+ last.open, last.high,
+ last.low, last.close,
+ last.volume*1e-6,
+ last.close-last.open )
+t4 = ax2.text(0.3, 0.9, s, transform=ax2.transAxes, fontsize=textsize)
- axUpper.plot( (0, N), [thresh, thresh], color=purple, linewidth=1)
- # lower horiz line
- axUpper.plot( (0, N), [-thresh, -thresh], color=purple, linewidth=1)
+props = font_manager.FontProperties(size=10)
+leg = ax2.legend(loc='center left', shadow=True, fancybox=True, prop=props)
+leg.get_frame().set_alpha(0.5)
+vmax = r.volume.max()/1e6
+poly = ax2t.fill_between(r.date, r.volume/1e6, 0, facecolor=fillcolor, label='Volume')
+ax2t.set_ylim(0, 5*vmax)
+ymax = np.int(vmax)
+yticks = [vmax/2., vmax]
+ax2t.set_yticks(yticks)
+ax2t.set_yticklabels(['%d M'%val for val in yticks])
- # fill above threshold
- fill_over(axUpper, vind, s, thresh, purple, over=True)
- fill_over(axUpper, vind, s, -thresh, purple, over=False)
+### compute the MACD indicator
+fillcolor = 'darkslategrey'
+nslow = 26
+nfast = 12
+nema = 9
+emaslow, emafast, macd = moving_average_convergence(prices, nslow=nslow, nfast=nfast)
+ema9 = moving_average(macd, nema, type='exponential')
+ax3.plot(r.date, macd, color='black', lw=2)
+ax3.plot(r.date, ema9, color='blue', lw=1)
+ax3.fill_between(r.date, macd-ema9, 0, facecolor=fillcolor, alpha=0.5)
- t = axUpper.set_title('Google (GOOG)', fontsize=12)
- t.set_y(1.05) # move it up a bit higher than the default
- t.set_x(0) # align the title left, axes coords
- t.set_horizontalalignment('left') # align the title left, axes coords
- axUpper.yaxis.set_major_locator( MultipleLocator(5) )
+ax3.text(0.025, 0.95, 'MACD (%d, %d, %d)'%(nfast, nslow, nema), va='top',
+ transform=ax3.transAxes, fontsize=textsize)
+ax3.set_yticks([])
+# turn off tick labels, rorate them, etc
+for ax in ax1, ax2, ax2t, ax3:
+ if ax!=ax3:
+ for label in ax.get_xticklabels():
+ label.set_visible(False)
+ else:
+ for label in ax.get_xticklabels():
+ label.set_rotation(30)
+ label.set_horizontalalignment('right')
- # now add some text
- left, height, top = 0.025, 0.06, 0.85
- t = axUpper.text(left, top, 'RSI(14) 51.0', fontsize=textsize,
- transform=axUpper.transAxes)
+ ax.fmt_xdata = mdates.DateFormatter('%Y-%m-%d')
+class PriceFormatter(mticker.FormatStrFormatter):
+ 'suppress the lowest tick label to prevent overlap'
+ def __call__(self, x, pos=None):
+ if pos==0:
+ return ''
+ else:
+ return mticker.FormatStrFormatter.__call__(self, x, pos=None)
-if 1: ############### Middle axes #################
+ax2.yaxis.set_major_formatter(PriceFormatter('%d'))
+plt.show()
- candlestick2(axMiddle, r.open, r.close, r.high, r.low, width=0.9)
-
- # specify the text in axes (0,1) coords. 0,0 is lower left and 1,1 is
- # upper right
-
- left, height, top = 0.025, 0.06, 0.9
- t1 = axMiddle.text(left, top, '%s daily'%ticker, fontsize=textsize,
- transform=axMiddle.transAxes)
- t2 = axMiddle.text(left, top-height, 'MA(5)', color='b', fontsize=textsize,
- transform=axMiddle.transAxes)
- t3 = axMiddle.text(left, top-2*height, 'MA(20)', color='r', fontsize=textsize,
- transform=axMiddle.transAxes)
-
- s = '%s O:%1.2f H:%1.2f L:%1.2f C:%1.2f, V:%1.1fM Chg:%+1.2f' %(
- time.strftime('%d-%b-%Y'),
- r.open[-1], r.high[-1],
- r.low[-1], r.close[-1],
- r.volume[-1]*1e-6,
- r.close[-1]-r.open[-1])
- t4 = axMiddle.text(0.4, top, s, fontsize=textsize,
- transform=axMiddle.transAxes)
-
-
- # now do the moviing average. I'll use a convolution to simulate a
- # real moving average
- ma5 = movavg(r.adj_close, 5)
- ma20 = movavg(r.adj_close, 20)
- axMiddle.plot(vind[5-1:], ma5, 'b', linewidth=1)
- axMiddle.plot(vind[20-1:], ma20, 'r', linewidth=1)
-
- axMiddle.set_ylim((300, 800))
- axMiddle.set_yticks(np.arange(800, 800, 100))
-
- # Now do the volume overlay
-
- # todo - this is broken
- bars = volume_overlay(axMiddleVol, r.open, r.close, r.volume, alpha=0.5)
- #axMiddleVol.set_ylim(0, 3*r.volume.max()) # use only a third of the viewlim
-
-
-if 1: ############### Lower axes #################
-
- # make up two signals; I don't know what the signals are in real life
- # so I'll just illustrate the plotting stuff
- s1 = random_signal(N, 10)
- s2 = random_signal(N, 20)
-
- axLower.plot(vind, s1, color=purple)
- axLower.plot(vind, s2, color='k', linewidth=1.0)
- s3 = s2-s1
- axLower.plot(vind, s3, color='#cccc99') # wheat
- bars = index_bar(axLower, s3, width=2, alpha=0.5,
- facecolor='#3087c7', edgecolor='#cccc99')
- axLower.yaxis.set_major_locator(MultipleLocator(5))
-
-
- # now add some text
- left, height, top = 0.025, 0.06, 0.85
-
- t = axLower.text(left, top, 'MACD(12,26,9) -0.26', fontsize=textsize,
- transform=axLower.transAxes)
-
- # make sure everyone has the same axes limits
-
- setp(axLower.get_xticklabels(), 'rotation', 45,
- 'horizontalalignment', 'right', fontsize=8)
-
-# force all the axes to have the same x data limits
-allAxes = (axUpper, axMiddle, axMiddleVol, axLower)
-xlim = 0, N
-for a in allAxes:
- a.set_xlim(xlim)
-
-for ax in axUpper, axMiddle, axMiddleVol:
- for ticklabel in ax.get_xticklabels():
- ticklabel.set_visible(False)
-
-show()
Modified: trunk/matplotlib/examples/pylab_examples/legend_demo3.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/legend_demo3.py 2009-03-18 07:39:43 UTC (rev 6987)
+++ trunk/matplotlib/examples/pylab_examples/legend_demo3.py 2009-03-18 15:22:41 UTC (rev 6988)
@@ -23,7 +23,7 @@
ax3 = plt.subplot(3,1,3)
myplot(ax3)
-ax3.legend(loc=1, ncol=4, mode="expand", shadow=True)
+ax3.legend(shadow=True, fancybox=True)
plt.draw()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-06-05 16:53:13
|
Revision: 7181
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7181&view=rev
Author: jdh2358
Date: 2009-06-05 16:53:11 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
renamed fill_between.py and fill_betweenx.py to have _demo postfix
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/fill_between_demo.py
trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab_examples/fill_between.py
trunk/matplotlib/examples/pylab_examples/fill_betweenx.py
Deleted: trunk/matplotlib/examples/pylab_examples/fill_between.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:51:21 UTC (rev 7180)
+++ trunk/matplotlib/examples/pylab_examples/fill_between.py 2009-06-05 16:53:11 UTC (rev 7181)
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-import matplotlib.mlab as mlab
-from matplotlib.pyplot import figure, show
-import numpy as np
-
-x = np.arange(0.0, 2, 0.01)
-y1 = np.sin(2*np.pi*x)
-y2 = 1.2*np.sin(4*np.pi*x)
-
-fig = figure()
-ax1 = fig.add_subplot(311)
-ax2 = fig.add_subplot(312, sharex=ax1)
-ax3 = fig.add_subplot(313, sharex=ax1)
-
-ax1.fill_between(x, 0, y1)
-ax1.set_ylabel('between y1 and 0')
-
-ax2.fill_between(x, y1, 1)
-ax2.set_ylabel('between y1 and 1')
-
-ax3.fill_between(x, y1, y2)
-ax3.set_ylabel('between y1 and y2')
-ax3.set_xlabel('x')
-
-# now fill between y1 and y2 where a logical condition is met. Note
-# this is different than calling
-# fill_between(x[where], y1[where],y2[where]
-# because of edge effects over multiple contiguous regions.
-fig = figure()
-ax = fig.add_subplot(211)
-ax.plot(x, y1, x, y2, color='black')
-ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
-ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
-ax.set_title('fill between where')
-
-# Test support for masked arrays.
-y2 = np.ma.masked_greater(y2, 1.0)
-ax1 = fig.add_subplot(212, sharex=ax)
-ax1.plot(x, y1, x, y2, color='black')
-ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
-ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
-ax1.set_title('Now regions with y2>1 are masked')
-
-# This example illustrates a problem; because of the data
-# gridding, there are undesired unfilled triangles at the crossover
-# points. A brute-force solution would be to interpolate all
-# arrays to a very fine grid before plotting.
-
-# show how to use transforms to create axes spans where a certain condition is satisfied
-fig = figure()
-ax = fig.add_subplot(111)
-y = np.sin(4*np.pi*x)
-ax.plot(x, y, color='black')
-
-# use the data coordinates for the x-axis and the axes coordinates for the y-axis
-import matplotlib.transforms as mtransforms
-trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
-theta = 0.9
-ax.axhline(theta, color='green', lw=2, alpha=0.5)
-ax.axhline(-theta, color='red', lw=2, alpha=0.5)
-ax.fill_between(x, 0, 1, where=y>theta, facecolor='green', alpha=0.5, transform=trans)
-ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans)
-
-
-
-show()
-
Copied: trunk/matplotlib/examples/pylab_examples/fill_between_demo.py (from rev 7180, trunk/matplotlib/examples/pylab_examples/fill_between.py)
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_between_demo.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/fill_between_demo.py 2009-06-05 16:53:11 UTC (rev 7181)
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+import matplotlib.mlab as mlab
+from matplotlib.pyplot import figure, show
+import numpy as np
+
+x = np.arange(0.0, 2, 0.01)
+y1 = np.sin(2*np.pi*x)
+y2 = 1.2*np.sin(4*np.pi*x)
+
+fig = figure()
+ax1 = fig.add_subplot(311)
+ax2 = fig.add_subplot(312, sharex=ax1)
+ax3 = fig.add_subplot(313, sharex=ax1)
+
+ax1.fill_between(x, 0, y1)
+ax1.set_ylabel('between y1 and 0')
+
+ax2.fill_between(x, y1, 1)
+ax2.set_ylabel('between y1 and 1')
+
+ax3.fill_between(x, y1, y2)
+ax3.set_ylabel('between y1 and y2')
+ax3.set_xlabel('x')
+
+# now fill between y1 and y2 where a logical condition is met. Note
+# this is different than calling
+# fill_between(x[where], y1[where],y2[where]
+# because of edge effects over multiple contiguous regions.
+fig = figure()
+ax = fig.add_subplot(211)
+ax.plot(x, y1, x, y2, color='black')
+ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
+ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
+ax.set_title('fill between where')
+
+# Test support for masked arrays.
+y2 = np.ma.masked_greater(y2, 1.0)
+ax1 = fig.add_subplot(212, sharex=ax)
+ax1.plot(x, y1, x, y2, color='black')
+ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green')
+ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red')
+ax1.set_title('Now regions with y2>1 are masked')
+
+# This example illustrates a problem; because of the data
+# gridding, there are undesired unfilled triangles at the crossover
+# points. A brute-force solution would be to interpolate all
+# arrays to a very fine grid before plotting.
+
+# show how to use transforms to create axes spans where a certain condition is satisfied
+fig = figure()
+ax = fig.add_subplot(111)
+y = np.sin(4*np.pi*x)
+ax.plot(x, y, color='black')
+
+# use the data coordinates for the x-axis and the axes coordinates for the y-axis
+import matplotlib.transforms as mtransforms
+trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
+theta = 0.9
+ax.axhline(theta, color='green', lw=2, alpha=0.5)
+ax.axhline(-theta, color='red', lw=2, alpha=0.5)
+ax.fill_between(x, 0, 1, where=y>theta, facecolor='green', alpha=0.5, transform=trans)
+ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans)
+
+
+
+show()
+
Deleted: trunk/matplotlib/examples/pylab_examples/fill_betweenx.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_betweenx.py 2009-06-05 16:51:21 UTC (rev 7180)
+++ trunk/matplotlib/examples/pylab_examples/fill_betweenx.py 2009-06-05 16:53:11 UTC (rev 7181)
@@ -1,50 +0,0 @@
-import matplotlib.mlab as mlab
-from matplotlib.pyplot import figure, show
-import numpy as np
-
-## Copy of fill_between.py but using fill_betweenx() instead.
-
-x = np.arange(0.0, 2, 0.01)
-y1 = np.sin(2*np.pi*x)
-y2 = 1.2*np.sin(4*np.pi*x)
-
-fig = figure()
-ax1 = fig.add_subplot(311)
-ax2 = fig.add_subplot(312, sharex=ax1)
-ax3 = fig.add_subplot(313, sharex=ax1)
-
-ax1.fill_betweenx(x, 0, y1)
-ax1.set_ylabel('between y1 and 0')
-
-ax2.fill_betweenx(x, y1, 1)
-ax2.set_ylabel('between y1 and 1')
-
-ax3.fill_betweenx(x, y1, y2)
-ax3.set_ylabel('between y1 and y2')
-ax3.set_xlabel('x')
-
-# now fill between y1 and y2 where a logical condition is met. Note
-# this is different than calling
-# fill_between(x[where], y1[where],y2[where]
-# because of edge effects over multiple contiguous regions.
-fig = figure()
-ax = fig.add_subplot(211)
-ax.plot(y1, x, y2, x, color='black')
-ax.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green')
-ax.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red')
-ax.set_title('fill between where')
-
-# Test support for masked arrays.
-y2 = np.ma.masked_greater(y2, 1.0)
-ax1 = fig.add_subplot(212, sharex=ax)
-ax1.plot(y1, x, y2, x, color='black')
-ax1.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green')
-ax1.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red')
-ax1.set_title('Now regions with y2 > 1 are masked')
-
-# This example illustrates a problem; because of the data
-# gridding, there are undesired unfilled triangles at the crossover
-# points. A brute-force solution would be to interpolate all
-# arrays to a very fine grid before plotting.
-
-show()
Copied: trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py (from rev 7178, trunk/matplotlib/examples/pylab_examples/fill_betweenx.py)
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/fill_betweenx_demo.py 2009-06-05 16:53:11 UTC (rev 7181)
@@ -0,0 +1,50 @@
+import matplotlib.mlab as mlab
+from matplotlib.pyplot import figure, show
+import numpy as np
+
+## Copy of fill_between.py but using fill_betweenx() instead.
+
+x = np.arange(0.0, 2, 0.01)
+y1 = np.sin(2*np.pi*x)
+y2 = 1.2*np.sin(4*np.pi*x)
+
+fig = figure()
+ax1 = fig.add_subplot(311)
+ax2 = fig.add_subplot(312, sharex=ax1)
+ax3 = fig.add_subplot(313, sharex=ax1)
+
+ax1.fill_betweenx(x, 0, y1)
+ax1.set_ylabel('between y1 and 0')
+
+ax2.fill_betweenx(x, y1, 1)
+ax2.set_ylabel('between y1 and 1')
+
+ax3.fill_betweenx(x, y1, y2)
+ax3.set_ylabel('between y1 and y2')
+ax3.set_xlabel('x')
+
+# now fill between y1 and y2 where a logical condition is met. Note
+# this is different than calling
+# fill_between(x[where], y1[where],y2[where]
+# because of edge effects over multiple contiguous regions.
+fig = figure()
+ax = fig.add_subplot(211)
+ax.plot(y1, x, y2, x, color='black')
+ax.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green')
+ax.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red')
+ax.set_title('fill between where')
+
+# Test support for masked arrays.
+y2 = np.ma.masked_greater(y2, 1.0)
+ax1 = fig.add_subplot(212, sharex=ax)
+ax1.plot(y1, x, y2, x, color='black')
+ax1.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green')
+ax1.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red')
+ax1.set_title('Now regions with y2 > 1 are masked')
+
+# This example illustrates a problem; because of the data
+# gridding, there are undesired unfilled triangles at the crossover
+# points. A brute-force solution would be to interpolate all
+# arrays to a very fine grid before plotting.
+
+show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-05 16:23:16
|
Revision: 7383
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7383&view=rev
Author: jdh2358
Date: 2009-08-05 16:23:06 +0000 (Wed, 05 Aug 2009)
Log Message:
-----------
removed examples/data; ported all examples to use sample_data
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/date_index_formatter.py
trunk/matplotlib/examples/pylab_examples/image_demo2.py
trunk/matplotlib/examples/pylab_examples/load_converter.py
trunk/matplotlib/examples/pylab_examples/loadrec.py
trunk/matplotlib/examples/pylab_examples/logo.py
trunk/matplotlib/examples/pylab_examples/plotfile_demo.py
Modified: trunk/matplotlib/examples/pylab_examples/date_index_formatter.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/date_index_formatter.py 2009-08-05 16:21:23 UTC (rev 7382)
+++ trunk/matplotlib/examples/pylab_examples/date_index_formatter.py 2009-08-05 16:23:06 UTC (rev 7383)
@@ -14,7 +14,7 @@
import matplotlib.cbook as cbook
from matplotlib.ticker import Formatter
-datafile = cbook.get_sample_data('msft.csv', asobj=False)
+datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
print 'loading', datafile
r = csv2rec(datafile)[-40:]
Modified: trunk/matplotlib/examples/pylab_examples/image_demo2.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_demo2.py 2009-08-05 16:21:23 UTC (rev 7382)
+++ trunk/matplotlib/examples/pylab_examples/image_demo2.py 2009-08-05 16:23:06 UTC (rev 7383)
@@ -1,9 +1,10 @@
#!/usr/bin/env python
from pylab import *
+import matplotlib.cbook as cbook
w, h = 512, 512
-datafile = cbook.get_sample_data('ct.raw', asobj=False)
+datafile = cbook.get_sample_data('ct.raw', asfileobj=False)
print 'loading', datafile
s = file(datafile, 'rb').read()
A = fromstring(s, uint16).astype(float)
Modified: trunk/matplotlib/examples/pylab_examples/load_converter.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/load_converter.py 2009-08-05 16:21:23 UTC (rev 7382)
+++ trunk/matplotlib/examples/pylab_examples/load_converter.py 2009-08-05 16:23:06 UTC (rev 7383)
@@ -4,7 +4,7 @@
from pylab import figure, show
import matplotlib.cbook as cbook
-datafile = cbook.get_sample_data('msft.csv', asobj=False)
+datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
print 'loading', datafile
dates, closes = np.loadtxt(
Modified: trunk/matplotlib/examples/pylab_examples/loadrec.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/loadrec.py 2009-08-05 16:21:23 UTC (rev 7382)
+++ trunk/matplotlib/examples/pylab_examples/loadrec.py 2009-08-05 16:23:06 UTC (rev 7383)
@@ -2,7 +2,7 @@
from pylab import figure, show
import matplotlib.cbook as cbook
-datafile = cbook.get_sample_data('msft.csv', asobj=False)
+datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
print 'loading', datafile
a = mlab.csv2rec(datafile)
a.sort()
Modified: trunk/matplotlib/examples/pylab_examples/logo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/logo.py 2009-08-05 16:21:23 UTC (rev 7382)
+++ trunk/matplotlib/examples/pylab_examples/logo.py 2009-08-05 16:23:06 UTC (rev 7383)
@@ -4,7 +4,7 @@
# convert data to mV
-datafile = cbook.get_sample_data('membrane.dat', asobj=False)
+datafile = cbook.get_sample_data('membrane.dat', asfileobj=False)
print 'loading', datafile
x = 1000*0.1*fromstring(file(datafile, 'rb').read(), float32)
Modified: trunk/matplotlib/examples/pylab_examples/plotfile_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/plotfile_demo.py 2009-08-05 16:21:23 UTC (rev 7382)
+++ trunk/matplotlib/examples/pylab_examples/plotfile_demo.py 2009-08-05 16:23:06 UTC (rev 7383)
@@ -1,8 +1,8 @@
from pylab import plotfile, show, gca
import matplotlib.cbook as cbook
-fname = cbook.get_sample_data('msft.csv', asobj=False)
-fname2 = cbook.get_sample_data('data_x_x2_x3.csv', asobj=False)
+fname = cbook.get_sample_data('msft.csv', asfileobj=False)
+fname2 = cbook.get_sample_data('data_x_x2_x3.csv', asfileobj=False)
# test 1; use ints
plotfile(fname, (0,5,6))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-05 16:31:02
|
Revision: 7385
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7385&view=rev
Author: jdh2358
Date: 2009-08-05 16:30:55 +0000 (Wed, 05 Aug 2009)
Log Message:
-----------
fixed a couple of missing cbook imports in sample_data examples
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/image_demo3.py
trunk/matplotlib/examples/pylab_examples/logo.py
Modified: trunk/matplotlib/examples/pylab_examples/image_demo3.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_demo3.py 2009-08-05 16:24:03 UTC (rev 7384)
+++ trunk/matplotlib/examples/pylab_examples/image_demo3.py 2009-08-05 16:30:55 UTC (rev 7385)
@@ -5,8 +5,10 @@
except ImportError, exc:
raise SystemExit("PIL must be installed to run this example")
+import matplotlib.cbook as cbook
+
datafile = cbook.get_sample_data('lena.jpg')
-lena = cbook.Image.open(datafile)
+lena = Image.open(datafile)
dpi = rcParams['figure.dpi']
figsize = lena.size[0]/dpi, lena.size[1]/dpi
Modified: trunk/matplotlib/examples/pylab_examples/logo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/logo.py 2009-08-05 16:24:03 UTC (rev 7384)
+++ trunk/matplotlib/examples/pylab_examples/logo.py 2009-08-05 16:30:55 UTC (rev 7385)
@@ -1,8 +1,8 @@
#!/usr/bin/env python
# This file generates the matplotlib web page logo
from pylab import *
+import matplotlib.cbook as cbook
-
# convert data to mV
datafile = cbook.get_sample_data('membrane.dat', asfileobj=False)
print 'loading', datafile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2010-03-20 08:58:15
|
Revision: 8202
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8202&view=rev
Author: fer_perez
Date: 2010-03-20 08:58:06 +0000 (Sat, 20 Mar 2010)
Log Message:
-----------
Renamed to match new function name.
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/subplots_demo.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py
Deleted: trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py 2010-03-20 08:57:37 UTC (rev 8201)
+++ trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py 2010-03-20 08:58:06 UTC (rev 8202)
@@ -1,63 +0,0 @@
-"""Examples illustrating the use of plt.subplots().
-
-This function creates a figure and a grid of subplots with a single call, while
-providing reasonable control over how the individual plots are created. For
-very refined tuning of subplot creation, you can still use add_subplot()
-directly on a new figure.
-"""
-
-import matplotlib.pyplot as plt
-import numpy as np
-
-# Simple data to display in various forms
-x = np.linspace(0, 2*np.pi, 400)
-y = np.sin(x**2)
-
-plt.close('all')
-
-# Just a figure and one subplot
-f, ax = plt.subplots()
-ax.plot(x, y)
-ax.set_title('Simple plot')
-
-# Two subplots, the axes array is 1-d
-f, axarr = plt.subplots(2, sharex=True)
-axarr[0].plot(x, y)
-axarr[0].set_title('Sharing X axis')
-axarr[1].scatter(x, y)
-
-# Two subplots, unpack the axes array immediately
-f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
-ax1.plot(x, y)
-ax1.set_title('Sharing Y axis')
-ax2.scatter(x, y)
-
-# Three subplots sharing both x/y axes
-f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True)
-ax1.plot(x, y)
-ax1.set_title('Sharing both axes')
-ax2.scatter(x, y)
-ax3.scatter(x, 2*y**2-1,color='r')
-# Fine-tune figure; make subplots close to each other and hide x ticks for
-# all but bottom plot.
-f.subplots_adjust(hspace=0)
-plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)
-
-# Four axes, returned as a 2-d array
-f, axarr = plt.subplots(2, 2)
-axarr[0,0].plot(x, y)
-axarr[0,0].set_title('Axis [0,0]')
-axarr[0,1].scatter(x, y)
-axarr[0,1].set_title('Axis [0,1]')
-axarr[1,0].plot(x, y**2)
-axarr[1,0].set_title('Axis [1,0]')
-axarr[1,1].scatter(x, y**2)
-axarr[1,1].set_title('Axis [1,1]')
-# Fine-tune figure; hide x ticks for top plots and y ticks for right plots
-plt.setp([a.get_xticklabels() for a in axarr[0,:]], visible=False)
-plt.setp([a.get_yticklabels() for a in axarr[:,1]], visible=False)
-
-# Four polar axes
-plt.subplots(2, 2, subplot_kw=dict(polar=True))
-
-plt.show()
Copied: trunk/matplotlib/examples/pylab_examples/subplots_demo.py (from rev 8201, trunk/matplotlib/examples/pylab_examples/fig_subplot_demo.py)
===================================================================
--- trunk/matplotlib/examples/pylab_examples/subplots_demo.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/subplots_demo.py 2010-03-20 08:58:06 UTC (rev 8202)
@@ -0,0 +1,63 @@
+"""Examples illustrating the use of plt.subplots().
+
+This function creates a figure and a grid of subplots with a single call, while
+providing reasonable control over how the individual plots are created. For
+very refined tuning of subplot creation, you can still use add_subplot()
+directly on a new figure.
+"""
+
+import matplotlib.pyplot as plt
+import numpy as np
+
+# Simple data to display in various forms
+x = np.linspace(0, 2*np.pi, 400)
+y = np.sin(x**2)
+
+plt.close('all')
+
+# Just a figure and one subplot
+f, ax = plt.subplots()
+ax.plot(x, y)
+ax.set_title('Simple plot')
+
+# Two subplots, the axes array is 1-d
+f, axarr = plt.subplots(2, sharex=True)
+axarr[0].plot(x, y)
+axarr[0].set_title('Sharing X axis')
+axarr[1].scatter(x, y)
+
+# Two subplots, unpack the axes array immediately
+f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
+ax1.plot(x, y)
+ax1.set_title('Sharing Y axis')
+ax2.scatter(x, y)
+
+# Three subplots sharing both x/y axes
+f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True)
+ax1.plot(x, y)
+ax1.set_title('Sharing both axes')
+ax2.scatter(x, y)
+ax3.scatter(x, 2*y**2-1,color='r')
+# Fine-tune figure; make subplots close to each other and hide x ticks for
+# all but bottom plot.
+f.subplots_adjust(hspace=0)
+plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)
+
+# Four axes, returned as a 2-d array
+f, axarr = plt.subplots(2, 2)
+axarr[0,0].plot(x, y)
+axarr[0,0].set_title('Axis [0,0]')
+axarr[0,1].scatter(x, y)
+axarr[0,1].set_title('Axis [0,1]')
+axarr[1,0].plot(x, y**2)
+axarr[1,0].set_title('Axis [1,0]')
+axarr[1,1].scatter(x, y**2)
+axarr[1,1].set_title('Axis [1,1]')
+# Fine-tune figure; hide x ticks for top plots and y ticks for right plots
+plt.setp([a.get_xticklabels() for a in axarr[0,:]], visible=False)
+plt.setp([a.get_yticklabels() for a in axarr[:,1]], visible=False)
+
+# Four polar axes
+plt.subplots(2, 2, subplot_kw=dict(polar=True))
+
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|