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

Fix beach pdf output when Axes instance is provided to plot into #3241

Closed
wants to merge 1 commit into from

Conversation

megies
Copy link
Member

@megies megies commented Dec 16, 2022

What does this PR do?

This commit is a bug fix, which corrects a bug in the obspy/imaging/…beachball functions.

Specifically, when calling the functions beach(...) in obspy/imaging/mopad_wrapper.py or obspy/imaging/beachball.py with the arguments axes not equals None, there is always an error if save the plotted beachballs into vector files (e.g., .pdf or .eps).

To locate the error/bug, I found that the functions beach(...) calls the function matplotlib.transforms.IdentityTransform() to create a Transform object. However the created object does not have the method translate(...) that is essential for saving plots into vector files.

To fix the bug, it is simple by using the function matplotlib.transforms.Affine2D(np.identity(3)) instead of matplotlib.transforms.IdentityTransform() to create the Transform object. The object created by the former has the method translate(...) and hence allows for saving into vector files, while the object created by the latter does not. Excep this difference, the objects created by the two functions have the same behaviours.

Why was it initiated? Any relevant Issues?

fixes #2887

PR Checklist

  • Correct base branch selected? master for new features, maintenance_... for bug fixes
  • This PR is not directly related to an existing issue (which has no PR yet).
  • While the PR is still work-in-progress, the no_ci label can be added to skip CI builds
  • If the PR is making changes to documentation, docs pages can be built automatically.
    Just add the build_docs tag to this PR.
    Docs will be served at docs.obspy.org/pr/{branch_name} (do not use master branch).
    Please post a link to the relevant piece of documentation.
  • If all tests including network modules (e.g. clients.fdsn) should be tested for the PR,
    just add the test_network tag to this PR.
  • All tests still pass.
  • Any new features or fixed regressions are covered via new tests.
  • Any new or changed features are fully documented.
  • Significant changes have been added to CHANGELOG.txt .
  • First time contributors have added your name to CONTRIBUTORS.txt .
  • If the changes affect any plotting functions you have checked that the plots
    from all the CI builds look correct. Add the "upload_plots" tag so that plotting
    outputs are attached as artifacts.
  • New modules, add the module to CODEOWNERS with your github handle
  • Add the ready for review tag when you are ready for the PR to be reviewed.

…beachball` functions.

Specifically, when calling the functions `beach(...)` in `obspy/imaging/mopad_wrapper.py` or
`obspy/imaging/beachball.py` with the arguments `axes` not equals `None`, there is always
an error if save the plotted beachballs into vector files (e.g., .pdf or .eps).

To locate the error/bug, I found that the functions `beach(...)` calls the function
`matplotlib.transforms.IdentityTransform()` to create a Transform object. However the
created object does not have the method `translate(...)` that is essential for saving
plots into vector files.

To fix the bug, it is simple by using the function `matplotlib.transforms.Affine2D(np.identity(3))`
instead of `matplotlib.transforms.IdentityTransform()` to create the Transform object.
The object created by the former has the method `translate(...)` and hence allows for
saving into vector files, while the object created by the latter does not.
Excep this difference, the objects created by the two functions have the same behaviours.
@megies megies added bug confirmed bug .imaging Issues with our plotting functionalities labels Dec 16, 2022
@megies megies added this to the 1.4.1 milestone Dec 16, 2022
@megies
Copy link
Member Author

megies commented Dec 16, 2022

Closing for a new PR where we can add commits with original commit cherry-picked.

@megies megies closed this Dec 16, 2022
@megies megies added the duplicate Duplicate of another issue label Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed bug duplicate Duplicate of another issue .imaging Issues with our plotting functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants