Skip to content

BboxConnectorPatch does not show facecolor #8059

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

Closed
jotasi opened this issue Feb 10, 2017 · 11 comments
Closed

BboxConnectorPatch does not show facecolor #8059

jotasi opened this issue Feb 10, 2017 · 11 comments

Comments

@jotasi
Copy link

jotasi commented Feb 10, 2017

Bug report

Bug summary

When adding a BboxConnectorPatch, the edges are displayed correctly but the facecolor is not shown. The face is empty.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.transforms import Bbox, TransformedBbox, \
     blended_transform_factory
from mpl_toolkits.axes_grid1.inset_locator import BboxPatch, BboxConnector,\
     BboxConnectorPatch
fig, ax = plt.subplots(1, 2)
fig.set_size_inches(12, 6)
fig.set_tight_layout(True)
ax[0].set_xlim(0, 1)
ax[0].set_ylim(0, 1)
ax[1].set_xlim(0, 1)
ax[1].set_ylim(0.35, 0.65)
trans1 = blended_transform_factory(ax[0].transData, ax[0].transData)
trans2 = blended_transform_factory(ax[1].transData, ax[1].transData)
bbox = Bbox.from_extents(0, 0.4, 1, 0.6)
bbox1 = TransformedBbox(bbox, trans1)
bbox2 = TransformedBbox(bbox, trans2)
p = BboxConnectorPatch(bbox1, bbox2,
                       loc1a=1, loc2a=2, loc1b=4, loc2b=3, ec="b", fc="b")
p.set_clip_on(False)
ax[0].add_patch(p)
ax[1].yaxis.tick_right()
plt.show()

Actual outcome

download

Expected outcome

I would expect the trapezoid to be filled in blue rather than to be empty.

Matplotlib version
Matplotlib version: 2.0.0
Python version: 3.4.2
Platform: Linux
Python was installed from the debian repositories and matplotlib was installed via pip.

@tacaswell
Copy link
Member

Did this use to work with 1.5?

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Feb 10, 2017
@tacaswell
Copy link
Member

I confirmed that this is a regression from 1.5

@tacaswell
Copy link
Member

Something is setting the alpha on the face color to 0 when you go through set_facecolor, but if you reach in and set p._facecolor directly it renders correctly.

This is....odd.

@jotasi
Copy link
Author

jotasi commented Feb 10, 2017

I can confirm as well that this is a regression from 1.5. I also noted another thing. The trapezoid is shifted a pixel to the left:

Matplotlib 1.5:
matplotlib1 5

Matplotlib 2.0:
matplotlib2 0

Is this just me using a wrong input for the boundaries and the difference is just in the line thickness or is this another small bug? If so, should I open another issue for this or should I just leave that here?

@jotasi jotasi closed this as completed Feb 10, 2017
@tacaswell
Copy link
Member

Ah this makes sense now, the init methods of BboxConnectorPatch is setting fill=False to fix #5757

There just needs to be some logic in inset_locator.py to identify when a face color is passed in and not pass fill=False.

In the mean time, the work around is to do

p.set_fill(True)
p.set_facecolor('b')

@jotasi jotasi reopened this Feb 10, 2017
@jotasi
Copy link
Author

jotasi commented Feb 10, 2017

Sorry clicked the wrong button, I did not mean to close this...

@jotasi
Copy link
Author

jotasi commented Feb 10, 2017

Good to know. Thanks @tacaswell!

@tacaswell
Copy link
Member

And the pixel overflow is likely due to pixel snapping / anti-aliasing / edgewidth / dpi changes.

@jotasi
Copy link
Author

jotasi commented Feb 10, 2017

Ok. Looking at a zoom of the original picture I posted, it seems that the trapezoid's borders are to the left of both axes but that might just be because the line thickness is exactly a pixel in that case.

@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.0.3 (next bug fix release) Jun 30, 2017
@dstansby
Copy link
Member

If anyone is interested in fixing this, #8075 (comment) has a proposed solution.

@tacaswell tacaswell modified the milestones: 2.2 (next next feature release), 2.1 (next point release) Jul 11, 2017
zhoubecky added a commit to CinnyCao/matplotlib that referenced this issue Mar 5, 2018
zhoubecky added a commit to CinnyCao/matplotlib that referenced this issue Mar 5, 2018
zhoubecky added a commit to CinnyCao/matplotlib that referenced this issue Mar 6, 2018
* master: (107 commits)
  Remove incorrect warning in gca().
  Re-add of changes for flake8 and __cmp__ updates
  Py3fy backend_pgf.
  Fix tk icon loading.
  Add upstream link for PYOSINPUTHOOK_REPETITIVE.
  Remove outdated  Py_TPFLAGS_HAVE_NEWBUFFER flag.
  Remove C checks for old PY_*VERSION*.
  Remove C checks for PY3K macro.
  Remove back-compat defined for old NumPy.
  Rename #include guards without using reserved names.
  Py3fy font_manager.
  Enable enter/leave notify for tk
  bump warnings
  backend gtk3, qt5/qt4 and wx pass in coordinates when entering figure.
  figure_enter_event uses now LocationEvent instead of Event. This is now consistent with the documentation: https://matplotlib.org/users/event_handling.html
  Some py3fication for matplotlib/__init__, setupext.
  Move API change
  Add API changes
  Remove old nose testing code
  Filter out invalid value warnings in log scaling
  ...
@tacaswell tacaswell modified the milestones: needs sorting, v3.0 Mar 8, 2018
zhoubecky added a commit to CinnyCao/matplotlib that referenced this issue Mar 8, 2018
zhoubecky added a commit to CinnyCao/matplotlib that referenced this issue Mar 8, 2018
zhoubecky added a commit to CinnyCao/matplotlib that referenced this issue Mar 18, 2018
jklymak referenced this issue Mar 21, 2018
fix BboxConnectorPatch does not show facecolor
@tacaswell tacaswell modified the milestones: v3.0, v3.1 Aug 11, 2018
@jklymak
Copy link
Member

jklymak commented Feb 12, 2019

Closed by #10686

@jklymak jklymak closed this as completed Feb 12, 2019
@QuLogic QuLogic modified the milestones: v3.1.0, v3.0.0 Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants