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

Skip to content

Commit 712500d

Browse files
committed
Merge remote-tracking branch 'matplotlib/v1.5.x' into merge15xto2x
2 parents 3b8a6ec + 5bad764 commit 712500d

File tree

11 files changed

+125
-98
lines changed

11 files changed

+125
-98
lines changed

lib/matplotlib/animation.py

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ def grab_frame(self, **savefig_kwargs):
234234
# frame format and dpi.
235235
self.fig.savefig(self._frame_sink(), format=self.frame_format,
236236
dpi=self.dpi, **savefig_kwargs)
237-
except RuntimeError:
237+
except (RuntimeError, IOError) as e:
238238
out, err = self._proc.communicate()
239239
verbose.report('MovieWriter -- Error '
240240
'running proc:\n%s\n%s' % (out,
241241
err), level='helpful')
242-
raise
242+
raise IOError('Error saving animation to file (cause: {0}) '
243+
'Stdout: {1} StdError: {2}. It may help to re-run '
244+
'with --verbose-debug.'.format(e, out, err))
243245

244246
def _frame_sink(self):
245247
'Returns the place to which frames should be written.'
@@ -684,13 +686,28 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
684686
If nothing is passed, the value of the rcparam `animation.writer` is
685687
used.
686688
689+
*dpi* controls the dots per inch for the movie frames. This combined
690+
with the figure's size in inches controls the size of the movie.
691+
692+
*savefig_kwargs* is a dictionary containing keyword arguments to be
693+
passed on to the 'savefig' command which is called repeatedly to save
694+
the individual frames. This can be used to set tight bounding boxes,
695+
for example.
696+
697+
*extra_anim* is a list of additional `Animation` objects that should
698+
be included in the saved movie file. These need to be from the same
699+
`matplotlib.Figure` instance. Also, animation frames will just be
700+
simply combined, so there should be a 1:1 correspondence between
701+
the frames from the different animations.
702+
703+
These remaining arguments are used to construct a :class:`MovieWriter`
704+
instance when necessary and are only considered valid if *writer* is
705+
not a :class:`MovieWriter` instance.
706+
687707
*fps* is the frames per second in the movie. Defaults to None,
688708
which will use the animation's specified interval to set the frames
689709
per second.
690710
691-
*dpi* controls the dots per inch for the movie frames. This combined
692-
with the figure's size in inches controls the size of the movie.
693-
694711
*codec* is the video codec to be used. Not all codecs are supported
695712
by a given :class:`MovieWriter`. If none is given, this defaults to the
696713
value specified by the rcparam `animation.codec`.
@@ -708,18 +725,21 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
708725
*metadata* is a dictionary of keys and values for metadata to include
709726
in the output file. Some keys that may be of use include:
710727
title, artist, genre, subject, copyright, srcform, comment.
711-
712-
*extra_anim* is a list of additional `Animation` objects that should
713-
be included in the saved movie file. These need to be from the same
714-
`matplotlib.Figure` instance. Also, animation frames will just be
715-
simply combined, so there should be a 1:1 correspondence between
716-
the frames from the different animations.
717-
718-
*savefig_kwargs* is a dictionary containing keyword arguments to be
719-
passed on to the 'savefig' command which is called repeatedly to save
720-
the individual frames. This can be used to set tight bounding boxes,
721-
for example.
722728
'''
729+
# If the writer is None, use the rc param to find the name of the one
730+
# to use
731+
if writer is None:
732+
writer = rcParams['animation.writer']
733+
elif (not is_string_like(writer) and
734+
any(arg is not None
735+
for arg in (fps, codec, bitrate, extra_args, metadata))):
736+
raise RuntimeError('Passing in values for arguments for arguments '
737+
'fps, codec, bitrate, extra_args, or metadata '
738+
'is not supported when writer is an existing '
739+
'MovieWriter instance. These should instead be '
740+
'passed as arguments when creating the '
741+
'MovieWriter instance.')
742+
723743
if savefig_kwargs is None:
724744
savefig_kwargs = {}
725745

@@ -735,11 +755,6 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
735755
# Convert interval in ms to frames per second
736756
fps = 1000. / self._interval
737757

738-
# If the writer is None, use the rc param to find the name of the one
739-
# to use
740-
if writer is None:
741-
writer = rcParams['animation.writer']
742-
743758
# Re-use the savefig DPI for ours if none is given
744759
if dpi is None:
745760
dpi = rcParams['savefig.dpi']

lib/matplotlib/tests/test_path.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def test_contains_points_negative_radius():
3939
expected = [True, False, False]
4040
result = path.contains_points(points, radius=-0.5)
4141

42-
assert result.dtype == np.bool
4342
assert np.all(result == expected)
4443

4544

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,9 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
22402240
that *c* should not be a single numeric RGB or RGBA
22412241
sequence because that is indistinguishable from an array
22422242
of values to be colormapped. *c* can be a 2-D array in
2243-
which the rows are RGB or RGBA, however.
2243+
which the rows are RGB or RGBA, however, including the
2244+
case of a single row to specify the same color for
2245+
all points.
22442246
22452247
*depthshade*
22462248
Whether or not to shade the scatter markers to give
@@ -2269,15 +2271,15 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
22692271

22702272
s = np.ma.ravel(s) # This doesn't have to match x, y in size.
22712273

2272-
if c is None:
2273-
c = self._get_lines.get_next_color()
2274-
cstr = cbook.is_string_like(c) or cbook.is_sequence_of_strings(c)
2275-
if not cstr:
2276-
c = np.asanyarray(c)
2277-
if c.size == xs.size:
2278-
c = np.ma.ravel(c)
2279-
2280-
xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c)
2274+
if c is not None:
2275+
cstr = cbook.is_string_like(c) or cbook.is_sequence_of_strings(c)
2276+
if not cstr:
2277+
c = np.asanyarray(c)
2278+
if c.size == xs.size:
2279+
c = np.ma.ravel(c)
2280+
xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c)
2281+
else:
2282+
xs, ys, zs, s = cbook.delete_masked_points(xs, ys, zs, s)
22812283

22822284
patches = Axes.scatter(self, xs, ys, s=s, c=c, *args, **kwargs)
22832285
if not cbook.iterable(zs):

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ def test_scatter3d():
110110
c='b', marker='^')
111111

112112

113+
@image_comparison(baseline_images=['scatter3d_color'], remove_text=True,
114+
extensions=['png'])
115+
def test_scatter3d_color():
116+
fig = plt.figure()
117+
ax = fig.add_subplot(111, projection='3d')
118+
ax.scatter(np.arange(10), np.arange(10), np.arange(10),
119+
color='r', marker='o')
120+
ax.scatter(np.arange(10, 20), np.arange(10, 20), np.arange(10, 20),
121+
color='b', marker='s')
122+
123+
113124
@image_comparison(baseline_images=['surface3d'], remove_text=True)
114125
def test_surface3d():
115126
fig = plt.figure()

src/_backend_agg.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -956,13 +956,13 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
956956
typename PathGenerator::path_iterator path = path_generator(i);
957957

958958
if (Ntransforms) {
959-
typename TransformArray::sub_t subtrans = transforms[i % Ntransforms];
960-
trans = agg::trans_affine(subtrans(0, 0),
961-
subtrans(1, 0),
962-
subtrans(0, 1),
963-
subtrans(1, 1),
964-
subtrans(0, 2),
965-
subtrans(1, 2));
959+
int it = i % Ntransforms;
960+
trans = agg::trans_affine(transforms(it, 0, 0),
961+
transforms(it, 1, 0),
962+
transforms(it, 0, 1),
963+
transforms(it, 1, 1),
964+
transforms(it, 0, 2),
965+
transforms(it, 1, 2));
966966
trans *= master_transform;
967967
} else {
968968
trans = master_transform;
@@ -984,13 +984,13 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
984984
trans *= agg::trans_affine_translation(0.0, (double)height);
985985

986986
if (Nfacecolors) {
987-
typename ColorArray::sub_t facecolor = facecolors[i % Nfacecolors];
988-
face.second = agg::rgba(facecolor(0), facecolor(1), facecolor(2), facecolor(3));
987+
int ic = i % Nfacecolors;
988+
face.second = agg::rgba(facecolors(ic, 0), facecolors(ic, 1), facecolors(ic, 2), facecolors(ic, 3));
989989
}
990990

991991
if (Nedgecolors) {
992-
typename ColorArray::sub_t edgecolor = edgecolors[i % Nedgecolors];
993-
gc.color = agg::rgba(edgecolor(0), edgecolor(1), edgecolor(2), edgecolor(3));
992+
int ic = i % Nedgecolors;
993+
gc.color = agg::rgba(edgecolors(ic, 0), edgecolors(ic, 1), edgecolors(ic, 2), edgecolors(ic, 3));
994994

995995
if (Nlinewidths) {
996996
gc.linewidth = linewidths(i % Nlinewidths);
@@ -1269,8 +1269,8 @@ inline void RendererAgg::draw_gouraud_triangles(GCAgg &gc,
12691269
bool has_clippath = render_clippath(gc.clippath.path, gc.clippath.trans);
12701270

12711271
for (int i = 0; i < points.dim(0); ++i) {
1272-
typename PointArray::sub_t point = points[i];
1273-
typename ColorArray::sub_t color = colors[i];
1272+
typename PointArray::sub_t point = points.subarray(i);
1273+
typename ColorArray::sub_t color = colors.subarray(i);
12741274

12751275
_draw_gouraud_triangle(point, color, trans, has_clippath);
12761276
}

src/_image.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,12 @@ void pcolor(CoordinateArray &x,
120120
a10 = (1.0 - alpha) * beta;
121121
a11 = 1.0 - a00 - a01 - a10;
122122

123-
typename ColorArray::sub_t::sub_t start00 = d[rowstart[i]][colstart[j]];
124-
typename ColorArray::sub_t::sub_t start01 = d[rowstart[i]][colstart[j] + 1];
125-
typename ColorArray::sub_t::sub_t start10 = d[rowstart[i] + 1][colstart[j]];
126-
typename ColorArray::sub_t::sub_t start11 = d[rowstart[i] + 1][colstart[j] + 1];
127123
for (size_t k = 0; k < 4; ++k) {
128124
position[k] =
129-
start00(k) * a00 + start01(k) * a01 + start10(k) * a10 + start11(k) * a11;
125+
d(rowstart[i], colstart[j], k) * a00 +
126+
d(rowstart[i], colstart[j] + 1, k) * a01 +
127+
d(rowstart[i] + 1, colstart[j], k) * a10 +
128+
d(rowstart[i] + 1, colstart[j] + 1, k) * a11;
130129
}
131130
position += 4;
132131
}

0 commit comments

Comments
 (0)