8000 figure num=None, coll.color dep · matplotlib/matplotlib@c17e217 · GitHub
[go: up one dir, main page]

Skip to content

Commit c17e217

Browse files
committed
figure num=None, coll.color dep
svn path=/trunk/matplotlib/; revision=904
1 parent d09e4f6 commit c17e217

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

API_CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ API CHANGES in matplotlib-0.72
33
Line2D, Text, and Patch copy_properties renamed update_from and
44
moved into artist base class
55

6+
LineCollecitons.color renamed to LineCollections.set_color for
7+
consistency with set/get introspection mechanism,
8+
9+
610
API CHANGES in matplotlib-0.71
711

812
Significant numerix namespace changes, introduced to resolve

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
New entries should be added at the top
22

3+
2005-02-01 Added Fernando's figure num patch, including experemental
4+
support for pylab backend switching, LineCOllection.color
5+
warns - JDH
6+
37
2005-01-31 updated datalim in contour - JDH
48

59
2005-01-30 Added backend_qtagg.py provided by Sigve Tjora - SC

lib/matplotlib/collections.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
line segemnts)
99
"""
1010
import math
11-
from matplotlib import rcParams
11+
from matplotlib import rcParams, verbose
1212

1313
from artist import Artist
1414
from backend_bases import GraphicsContextBase
@@ -336,6 +336,15 @@ def set_color(self, c):
336336
ACCEPTS: matplotlib color arg or sequence of rgba tuples"""
337337
self._colors = self._get_color(c, len(self._colors))
338338

339+
def color(self, c):
340+
"""
341+
Set the color(s) of the line collection. c can be a matplotlib color arg
342+
(all patches have 10000 same color), or a a sequence or rgba tuples; if it
343+
is a sequence the patches will cycle through the sequence
344+
345+
ACCEPTS: matplotlib color arg or sequence of rgba tuples"""
346+
verbose.report_error('LineCollection.color deprecated; use set_color instead')
347+
return self.set_color(c)
339348

340349
def set_alpha(self, alpha):
341350
"""

lib/matplotlib/pylab.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
import mlab #so I can override hist, psd, etc...
189189

190190
from axes import Axes, PolarAxes
191+
import backends
191192
from backends import new_figure_manager, error_msg, \
192193
draw_if_interactive, show
193194

@@ -758,7 +759,7 @@ def figlegend(handles, labels, loc, **kwargs):
758759
return l
759760

760761

761-
def figure(num=1,
762+
def figure(num=None, # autoincrement if None, else integer from 1-N
762763
figsize = None, # defaults to rc figure.figsize
763764
dpi = None, # defaults to rc figure.dpi
764765
facecolor = None, # defaults to rc figure.facecolor
@@ -776,6 +777,9 @@ def figure(num=1,
776777
777778
figure(1)
778779
780+
If num=None, the figure number will be incremented and a new
781+
figure will be created.
782+
779783
figsize - width in height x inches; defaults to rc figure.figsize
780784
dpi - resolution; defaults to rc figure.dpi
781785
facecolor - the background color; defaults to rc figure.facecolor
@@ -794,6 +798,15 @@ def figure(num=1,
794798
if num==0:
795799
error_msg('Figure number can not be 0.\n' + \
796800
'Hey, give me a break, this is matlab(TM) compatability')
801+
return
802+
803+
804+
if num is None:
805+
allnums = [f.num for f in _pylab_helpers.Gcf.get_all_fig_managers()]
806+
if allnums:
807+
num = max(allnums) + 1
808+
else:
809+
num = 1
797810

798811
figManager = _pylab_helpers.Gcf.get_fig_manager(num)
799812
if figManager is None:
@@ -1585,6 +1598,16 @@ def ion():
15851598
'turn interactive mode on'
15861599
matplotlib.interactive(True)
15871600

1601+
1602+
def switch_backend(newbackend):
1603+
close('all')
1604+
global new_figure_manager, error_msg, draw_if_interactive, show
1605+
matplotlib.use(newbackend)
1606+
reload(backends)
1607+
from backends import new_figure_manager, error_msg, \
1608+
draw_if_interactive, show
1609+
1610+
15881611
### The following functions were autogenerated by the boilerplate.py
15891612
### script. They are simple wrappers around the Axes methods of the
15901613
### same name
@@ -2528,7 +2551,7 @@ def winter():
25282551
'Line2D', 'Polygon', 'Rectangle', 'Circle', 'Text', 'cm',
25292552
'get_cmap', 'normalize',
25302553

2531-
'show', 'rcParams'
2554+
'show', 'rcParams', 'switch_backend'
25322555
]
25332556

25342557

0 commit comments

Comments
 (0)
0