Skip to content
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

Bug fix for issue #955 #1001

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_macosx.py
Expand Up @@ -84,7 +84,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,

def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
coordinates, offsets, offsetTrans, facecolors,
antialiased, showedges):
antialiased, edgecolors):
cliprect = gc.get_clip_rectangle()
clippath, clippath_transform = gc.get_clip_path()
gc.draw_quad_mesh(master_transform,
Expand All @@ -98,7 +98,7 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
offsetTrans,
facecolors,
antialiased,
showedges)
edgecolors)

def new_gc(self):
self.gc.save()
Expand Down
3 changes: 3 additions & 0 deletions lib/mpl_toolkits/axes_grid1/axes_size.py
Expand Up @@ -99,6 +99,9 @@ def __init__(self, axes, aspect=1.):
self._aspect = aspect

def get_size(self, renderer):
#Reset the aspect. The grid aspect may have been changed.
self._aspect = self._axes.get_aspect()

l1, l2 = self._axes.get_ylim()
rel_size = abs(l2-l1)*self._aspect
abs_size = 0.
Expand Down
39 changes: 29 additions & 10 deletions src/_macosx.m
Expand Up @@ -1652,7 +1652,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
PyObject* offset_transform;
PyObject* facecolors;
int antialiased;
int showedges;
PyObject* edgecolors;

CGContextRef cr = self->cr;

Expand All @@ -1662,7 +1662,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
return NULL;
}

if(!PyArg_ParseTuple(args, "OOOOiiOOOOii",
if(!PyArg_ParseTuple(args, "OOOOiiOOOOiO",
&master_transform,
&cliprect,
&clippath,
Expand All @@ -1674,7 +1674,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
&offset_transform,
&facecolors,
&antialiased,
&showedges)) return NULL;
&edgecolors)) return NULL;

int ok = 1;
CGContextSaveGState(cr);
Expand Down Expand Up @@ -1777,7 +1777,9 @@ static BOOL _clip(CGContextRef cr, PyObject* object)

size_t Npaths = meshWidth * meshHeight;
size_t Nfacecolors = (size_t) PyArray_DIM(facecolors, 0);
if ((Nfacecolors == 0 && !showedges) || Npaths == 0)
size_t Nedgecolors = (size_t) PyArray_DIM(edgecolors, 0);

if ((Nfacecolors == 0 && Nedgecolors == 0) || Npaths == 0)
{
/* Nothing to do here */
goto exit;
Expand All @@ -1797,17 +1799,18 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
const double b = *(double*)PyArray_GETPTR2(facecolors, 0, 2);
const double a = *(double*)PyArray_GETPTR2(facecolors, 0, 3);
CGContextSetRGBFillColor(cr, r, g, b, a);
if (antialiased && !showedges)
if (antialiased && Nedgecolors == 0)
{
CGContextSetRGBStrokeColor(cr, r, g, b, a);
}
}

if (showedges)
if (Nedgecolors == 0)
{
CGContextSetRGBStrokeColor(cr, 0, 0, 0, 1);
edgecolors = facecolors;
}


double x, y;
for (ih = 0; ih < meshHeight; ih++)
{
Expand Down Expand Up @@ -1854,6 +1857,21 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
CGContextAddLines(cr, points, 4);
CGContextClosePath(cr);

if (Nedgecolors > 0)
{
npy_intp ei = i % Nedgecolors;
const double e_r = *(double*)PyArray_GETPTR2(edgecolors, ei, 0);
const double e_g = *(double*)PyArray_GETPTR2(edgecolors, ei, 1);
const double e_b = *(double*)PyArray_GETPTR2(edgecolors, ei, 2);
const double e_a = *(double*)PyArray_GETPTR2(edgecolors, ei, 3);

CGContextSetRGBStrokeColor(cr, e_r, e_g, e_b, e_a);
}
else
{
CGContextSetRGBStrokeColor(cr, 0, 0, 0, 1);
}

if (Nfacecolors > 1)
{
npy_intp fi = i % Nfacecolors;
Expand All @@ -1862,7 +1880,8 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
const double b = *(double*)PyArray_GETPTR2(facecolors, fi, 2);
const double a = *(double*)PyArray_GETPTR2(facecolors, fi, 3);
CGContextSetRGBFillColor(cr, r, g, b, a);
if (showedges)

if (Nedgecolors > 0)
{
CGContextDrawPath(cr, kCGPathFillStroke);
}
Expand All @@ -1878,7 +1897,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
}
else if (Nfacecolors==1)
{
if (showedges || antialiased)
if (Nedgecolors > 0 || antialiased)
{
CGContextDrawPath(cr, kCGPathFillStroke);
}
Expand All @@ -1887,7 +1906,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
CGContextFillPath(cr);
}
}
else if (showedges)
else if (Nedgecolors > 0)
{
CGContextStrokePath(cr);
}
Expand Down