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

Skip to content

Fix mutation_aspect incorrectly scaling FancyBbox #28877

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
wants to merge 3 commits into from

Conversation

Balthasar-eu
Copy link

@Balthasar-eu Balthasar-eu commented Sep 24, 2024

This commit changes the mutation_aspect from only affecting the y axis to affecting x and y axis in the correct ratio.

A demonstration is in the linked issue.

closes #28876

PR summary

PR checklist

This commit changes the mutation_aspect from only affecting the y axis to affecting x and y axis in the correct ratio.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@Balthasar-eu
Copy link
Author

Balthasar-eu commented Sep 24, 2024

I did not test this on the branch I commit from, but I used this code:

def get_path(self):
    """Return the mutated path of the rectangle."""
    boxstyle = self.get_boxstyle()
    m_aspect = math.sqrt(self.get_mutation_aspect())
    # Call boxstyle with y, height squeezed by aspect_ratio.
    path = boxstyle(
        self._x * m_aspect,
        self._y / m_aspect,
        self._width * m_aspect,
        self._height / m_aspect,
        self.get_mutation_scale(),
    )
    return Path(
        path.vertices * [1 / m_aspect, m_aspect],
        path.codes,
    )

FancyBboxPatch.get_path = get_path

And on top of the code in the linked issue and the resulting plot is the second plot on that issue.

@Balthasar-eu Balthasar-eu changed the title Fix mutation_aspect Fix mutation_aspect incorrectly scaling FancyBbox Sep 24, 2024
@timhoffm
Copy link
Member

timhoffm commented Oct 7, 2024

As discussed in the issue #28876, the behavior is consistent, reasonably documented (after #28900) and suits common usage patterns. Therefore, we don't want to introduce a breaking change through changing the behavior.

@Balthasar-eu anyway thanks for your contribution. While your PR did not make it, it lead to an improvement in our docs. 🎉

@timhoffm timhoffm closed this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: mutation_aspect for FancyBboxPatch does wrong scaling
2 participants