-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add a dpi transform to AuxTransformBox #7344
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
Conversation
136f895
to
ddf6d95
Compare
Please wait on considering this PR. |
That looks like it fixes a pretty major bug! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor pep8 nit. Otherwise, I think this looks good.
@@ -963,13 +966,18 @@ def get_extent(self, renderer): | |||
mtx = self.offset_transform.matrix_from_values(*_off) | |||
self.offset_transform.set_matrix(mtx) | |||
|
|||
return ub.width, ub.height, 0., 0. | |||
dpi_cor = renderer.points_to_pixels(1.) | |||
return ub.width*dpi_cor, ub.height*dpi_cor, 0., 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit: need spaces around *
for pep8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think pep8 is fine with that for arithmetic operators, it calls for consistency, readability/good judgment. Either way, when I make a revision to the PR that line will not be there(for a yet unknown reason).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pep8 is fine with that. Both the document and the tool.
On 2016/10/27 1:17 PM, Hassan Kibirige wrote:
The actual PEP 8 does, exactly as you say--but the automated checker (Sorry, I couldn't resist the digression.) |
@efiring, thanks for the digression I prefer the automated solution and you have put question marks around the efficacy of the tools I use. According the pep8 lib/matplotlib/offsetbox.py | grep 970 yields nothing. |
Because of course the automatic tool and the document can't be in agreement. On the plus side, I learned more about the actual document today. |
@dopplershift The tool and the document are on agreement on that particular point. |
I swear I've seen it error on that--apparently I'm wrong. |
You are not wrong. Just outdated :-D |
That's good to know--it's a big improvement. I think that |
If we want to be more reliable on enforcing pep8 on new patches, we could run flake8 on the diff of the patch instead of how we currently run pep8 (which only looks at whether the number of pep8 violations is lower or equal than the previous patch). Some projects do that (joblib, scikit-learn and maybe ipython/jupyter folks). It should be quite easy to set up. |
@has2k1 Do you mind explaining why we should wait on considering this PR? |
Apparently I don't understand pep8. 😁
@NelleV, The solution so far does not completely solve the problem, as straight forward as it may be! A slight (and not good looking) modification though yields better results but it is not stable. I will put up a more complete illustration that should aid in getting better help. |
Because @has2k1 has a better fix in the pipeline :D
Hi @has2k1 |
@NelleV, hold on for a day. I'll push update and a dump of my worksheet that shows the limitations. |
**Issue** While the children themselves (e.g. Text objects) to an AuxTransformBox do conform to the dpi of the figure, the locations of the objects do not. Therefore the space taken up by the AuxTransformBox remains just about fixed, regardless of dpi. The relative distance between any two objects in the AuxTransformBox remains absolutely fixed. This leads to "scaling" artefacts for *png* output when the dpi is not 72. **Solution** Add a similar dpi transformation to that done for the DrawingArea.
Try enabling the frame on the |
I did that. It is at the bottom. Some of it below the x-axis. |
Is this ready to go after a rebase? Or are there still problems with it? If so, is it really release-critical? |
I don't think this is one rebase away from being ready; there's still the question of what to do with You'll have to ask @NelleV why it's release critical. |
I am in agreement with @QuLogic. I have without success tried to find a fix for |
We can remove the release critical label, but this is a major bug. All the publications that use this are wrong, and we are probably talking thousands of publications. |
I'm not so sure it's that major. This bug only arises when using |
I'm un-critical-izing this as I don't think it will be fixed soon and I'm not so sure it's that critical. |
When the dpi is not 72, the legend text of the `colorbar` does not align with the ticks. The patch works for our case but has other complications, as a result it is not merged in Matplotlib. See: matplotlib/matplotlib#7344
I'm pretty confused if this really needs to be fixed or just closed. Hopefully one of the original proponents can chime in again? Otherwise I've marked stale and will close in a month or so. |
As I recall, it is not easy fix to this issue without breaking For my use case in Plotnine, I created a AuxTransformBox subclass that worked as I expected. |
I don't at all mind this going forward... I've just moved to draft, and feel free to update or start again if you are interested. I'm just cleaning up and haven't thought about it deeply. |
I'll close as abandoned here. |
Issue
While the children themselves (e.g. Text objects) of an AuxTransformBox
do conform to the dpi of the figure, the locations of the objects
do not. Therefore the space taken up by the AuxTransformBox remains
just about fixed, regardless of dpi. The relative distance between
any two objects in the AuxTransformBox remains absolutely fixed. This
leads to "scaling" artefacts for png output when the dpi is not 72.
Solution
Add a similar dpi transformation to that done for the DrawingArea.