Grid badly displayed with aitoff projection #562

Closed
ghost opened this Issue May 23, 2012 · 1 comment

Comments

Projects
None yet
1 participant
@ghost

ghost commented May 23, 2012

When trying to plot celestial object on the sky (basically with coordinates equivalent to latitude/longitude) using the aitoff projection of the coord_map function, the grid is badly displayed, i.e. residual horizontal lines are still displayed for latitudes non equal to zero along with their correct projections.

Here is the code to reproduce this bug:

library(ggplot2)
sky2 = data.frame(RA=0, Dec=0)
skyplot2 <- qplot(RA,Dec,data=sky2,xlim=c(0,360),ylim=c(-89.999,89.999),
xlab="R.A.(°)", ylab="Decl. (°)",main="Source repartition on the sky")
skyplot2 + coord_map(projection="aitoff",orientation=c(89.999,180,0)) + 
scale_y_continuous(breaks=(-2:2)*30,limits=c(-89.999,89.999)) + 
scale_x_continuous(breaks=(0:8)*45,limits=c(0,360), labels=c("","","","","","","","",""))

And the resulting image:
skyplot

A quick hack is available here: http://stackoverflow.com/questions/10706632/grid-badly-displayed-using-ggplot2

wch was assigned Jul 11, 2012

Collaborator

wch commented Aug 2, 2012

It looks like the problem is that in coord_render_bg.map, the xrange values are expanded to go outside the range [0,360].

Browsing inside that function:

Browse[1]> xrange
[1] -97.2 457.2

After they're projected, the grid lines actually wrap around, which is why there are the horizontal lines. I modified the code to draw semi-transparent lines, and it made the wraparound very apparent.

The solution is to limit xrange and yrange to values that won't wrap around.

wch closed this in 70ea0bc Aug 3, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment