简体   繁体   中英

In ggplot2, how do I move tick labes from the bottom to the top of a plot?

I am using ggplot2 to plot data using a map projection in which the longitude lines converge at the bottom of the plot. (The top of the plot is near the equator, the bottom near the south pole.) So, all the labels for the longitude lines are piled up on top of each other at the bottom. There is plenty of room at the top of the plot, though.

For example, this:

foo <- data.frame(delta=2*(-40:0),alpha=0:40)
p <- ggplot(foo,aes(x=alpha,y=delta))
p <- p + coord_map('orthographic',orientation=c(-40.0,25.0,0.0))
p <- p + geom_point()
p

Produces this:

带有重叠标签的情节

How to I move the labels to the top of the plot, where there is room?

This is kind of a cheat, but you could reverse your y-axis like this:

ggplot(foo,aes(x=alpha,y=-1*delta))

you'd have to explain that it is reversed, but at least it would readable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM