Skip to content

Merge 1.5.x to 2.x #6443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 36 additions & 21 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,14 @@ def grab_frame(self, **savefig_kwargs):
# frame format and dpi.
self.fig.savefig(self._frame_sink(), format=self.frame_format,
dpi=self.dpi, **savefig_kwargs)
except RuntimeError:
except (RuntimeError, IOError) as e:
out, err = self._proc.communicate()
verbose.report('MovieWriter -- Error '
'running proc:\n%s\n%s' % (out,
err), level='helpful')
raise
raise IOError('Error saving animation to file (cause: {0}) '
'Stdout: {1} StdError: {2}. It may help to re-run '
'with --verbose-debug.'.format(e, out, err))

def _frame_sink(self):
'Returns the place to which frames should be written.'
Expand Down Expand Up @@ -684,13 +686,28 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
If nothing is passed, the value of the rcparam `animation.writer` is
used.

*dpi* controls the dots per inch for the movie frames. This combined
with the figure's size in inches controls the size of the movie.

*savefig_kwargs* is a dictionary containing keyword arguments to be
passed on to the 'savefig' command which is called repeatedly to save
the individual frames. This can be used to set tight bounding boxes,
for example.

*extra_anim* is a list of additional `Animation` objects that should
be included in the saved movie file. These need to be from the same
`matplotlib.Figure` instance. Also, animation frames will just be
simply combined, so there should be a 1:1 correspondence between
the frames from the different animations.

These remaining arguments are used to construct a :class:`MovieWriter`
instance when necessary and are only considered valid if *writer* is
not a :class:`MovieWriter` instance.

*fps* is the frames per second in the movie. Defaults to None,
which will use the animation's specified interval to set the frames
per second.

*dpi* controls the dots per inch for the movie frames. This combined
with the figure's size in inches controls the size of the movie.

*codec* is the video codec to be used. Not all codecs are supported
by a given :class:`MovieWriter`. If none is given, this defaults to the
value specified by the rcparam `animation.codec`.
Expand All @@ -708,18 +725,21 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
*metadata* is a dictionary of keys and values for metadata to include
in the output file. Some keys that may be of use include:
title, artist, genre, subject, copyright, srcform, comment.

*extra_anim* is a list of additional `Animation` objects that should
be included in the saved movie file. These need to be from the same
`matplotlib.Figure` instance. Also, animation frames will just be
simply combined, so there should be a 1:1 correspondence between
the frames from the different animations.

*savefig_kwargs* is a dictionary containing keyword arguments to be
passed on to the 'savefig' command which is called repeatedly to save
the individual frames. This can be used to set tight bounding boxes,
for example.
'''
# If the writer is None, use the rc param to find the name of the one
# to use
if writer is None:
writer = rcParams['animation.writer']
elif (not is_string_like(writer) and
any(arg is not None
for arg in (fps, codec, bitrate, extra_args, metadata))):
raise RuntimeError('Passing in values for arguments for arguments '
'fps, codec, bitrate, extra_args, or metadata '
'is not supported when writer is an existing '
'MovieWriter instance. These should instead be '
'passed as arguments when creating the '
'MovieWriter instance.')

if savefig_kwargs is None:
savefig_kwargs = {}

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

# If the writer is None, use the rc param to find the name of the one
# to use
if writer is None:
writer = rcParams['animation.writer']

# Re-use the savefig DPI for ours if none is given
if dpi is None:
dpi = rcParams['savefig.dpi']
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def test_contains_points_negative_radius():
expected = [True, False, False]
result = path.contains_points(points, radius=-0.5)

assert result.dtype == np.bool
assert np.all(result == expected)


Expand Down
22 changes: 12 additions & 10 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,9 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
that *c* should not be a single numeric RGB or RGBA
sequence because that is indistinguishable from an array
of values to be colormapped. *c* can be a 2-D array in
which the rows are RGB or RGBA, however.
which the rows are RGB or RGBA, however, including the
case of a single row to specify the same color for
all points.

*depthshade*
Whether or not to shade the scatter markers to give
Expand Down Expand Up @@ -2269,15 +2271,15 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,

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

if c is None:
c = self._get_lines.get_next_color()
cstr = cbook.is_string_like(c) or cbook.is_sequence_of_strings(c)
if not cstr:
c = np.asanyarray(c)
if c.size == xs.size:
c = np.ma.ravel(c)

xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c)
if c is not None:
cstr = cbook.is_string_like(c) or cbook.is_sequence_of_strings(c)
if not cstr:
c = np.asanyarray(c)
if c.size == xs.size:
c = np.ma.ravel(c)
xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c)
else:
xs, ys, zs, s = cbook.delete_masked_points(xs, ys, zs, s)

patches = Axes.scatter(self, xs, ys, s=s, c=c, *args, **kwargs)
if not cbook.iterable(zs):
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions lib/mpl_toolkits/tests/test_mplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def test_scatter3d():
c='b', marker='^')


@image_comparison(baseline_images=['scatter3d_color'], remove_text=True,
extensions=['png'])
def test_scatter3d_color():
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(np.arange(10), np.arange(10), np.arange(10),
color='r', marker='o')
ax.scatter(np.arange(10, 20), np.arange(10, 20), np.arange(10, 20),
color='b', marker='s')


@image_comparison(baseline_images=['surface3d'], remove_text=True)
def test_surface3d():
fig = plt.figure()
Expand Down
26 changes: 13 additions & 13 deletions src/_backend_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -956,13 +956,13 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
typename PathGenerator::path_iterator path = path_generator(i);

if (Ntransforms) {
typename TransformArray::sub_t subtrans = transforms[i % Ntransforms];
trans = agg::trans_affine(subtrans(0, 0),
subtrans(1, 0),
subtrans(0, 1),
subtrans(1, 1),
subtrans(0, 2),
subtrans(1, 2));
int it = i % Ntransforms;
trans = agg::trans_affine(transforms(it, 0, 0),
transforms(it, 1, 0),
transforms(it, 0, 1),
transforms(it, 1, 1),
transforms(it, 0, 2),
transforms(it, 1, 2));
trans *= master_transform;
} else {
trans = master_transform;
Expand All @@ -984,13 +984,13 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
trans *= agg::trans_affine_translation(0.0, (double)height);

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

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

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

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

_draw_gouraud_triangle(point, color, trans, has_clippath);
}
Expand Down
9 changes: 4 additions & 5 deletions src/_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,12 @@ void pcolor(CoordinateArray &x,
a10 = (1.0 - alpha) * beta;
a11 = 1.0 - a00 - a01 - a10;

typename ColorArray::sub_t::sub_t start00 = d[rowstart[i]][colstart[j]];
typename ColorArray::sub_t::sub_t start01 = d[rowstart[i]][colstart[j] + 1];
typename ColorArray::sub_t::sub_t start10 = d[rowstart[i] + 1][colstart[j]];
typename ColorArray::sub_t::sub_t start11 = d[rowstart[i] + 1][colstart[j] + 1];
for (size_t k = 0; k < 4; ++k) {
position[k] =
start00(k) * a00 + start01(k) * a01 + start10(k) * a10 + start11(k) * a11;
d(rowstart[i], colstart[j], k) * a00 +
d(rowstart[i], colstart[j] + 1, k) * a01 +
d(rowstart[i] + 1, colstart[j], k) * a10 +
d(rowstart[i] + 1, colstart[j] + 1, k) * a11;
}
position += 4;
}
Expand Down
Loading