-
Notifications
You must be signed in to change notification settings - Fork 21
Compute tick angles by advancing a small amount in axes coordinates #46
Conversation
@@ -318,13 +327,18 @@ def _update_ticks(self, renderer): | |||
pixel0 = spine.data | |||
world0 = spine.world[:,self.coord_index] |
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.
Isn't this line a no-op because world0
is assigned to again in the following line?
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.
Indeed - we should try and figure out when this was introduced (I'll take a look at git blame)
This is a great idea, thanks! Will leave a few comments below. I think we should then wait for #41 to be merged since it adds image testing, then we can add a regression test for this. |
# See: | ||
# http://matplotlib.org/users/transforms_tutorial.html#the-transformation-pipeline | ||
transLimits = self.parent_axes.transLimits | ||
invertedTransLimits = transLimits.inverted() |
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.
If these are always going to be affine transformations with no rotation, I wonder whether it would be more efficient to simply find out what the scale from axes to data coordinates is and multiply/divide by these later on?
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.
If these are always going to be affine transformations with no rotation, I wonder whether it would be more efficient to simply find out what the scale from axes to data coordinates is and multiply/divide by these later on?
Yes, but it would be clearer and nearly as efficient to pass all of the ticks to transform()
as one big vector.
You might be able to eliminate the multiple transformation objects by using a blended transform.
@lpsinger - could you rebase this now that #41 has been merged? Also, it would be great if you could add the example you have above as an image test. To do this, you need to add a test to
If you don't have time to do this, we could merge it as-is and I or @anizami could add the image test. |
@lpsinger @astrofrog - I actually made a minor change so you can just generate the reference image by |
@anizami - great! |
@lpsinger - that'd be great, thanks! |
I have a unit test, but I cannot generate a reference image. I get:
EDIT: never mind, figured it out. |
@lpsinger - just to check, are you still planning on adding a reference image to this PR? It would be great to have a regression test to avoid this issue creeping back in future. |
This handles cases when a plot extends over a small number of pixels in the WCS projection, but a large distance or number of pixels in display coordinates. Addresses astrofrog#45.
@astrofrog - Since this options seems more relevant for developers, where do you recommend we document this? |
If your goal is to eventually put this code into Astropy, you could imitate their Developer Documentation section, which includes Testing Guidelines. |
Thanks @lpsinger! |
Compute tick angles by advancing a small amount in axes coordinates
@anizami - can you open an issue for now to remind ourselves to document the |
@astrofrog - Sure! |
@lpsinger - it looks like this doesn't work properly if the axes are not square. Let me know if you have time to look into how to fix this today. If not, then I can look into it. |
Yes, I'll take a look. Do you have an example script? |
@lpsinger - yes, simply take your example and make the figure e.g. 6x3:
|
Compute tick angles by advancing a small amount in axes coordinates
This handles cases when a plot extends over a small number of pixels in the WCS projection, but a large distance or number of pixels in display coordinates. Addresses #45.
Here is a modified test script. The ticks are red and extra-long to make them stand out better.