ggplot2极坐标轴标签位置 [英] ggplot2 polar plot axis label location

查看:658
本文介绍了ggplot2极坐标轴标签位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这只是一个老问题的扩展 ggplot2极坐标箭头

This is just a extension for a old question ggplot2 polar plot arrows

您会发现x轴不在most_out圆之内. 在ggplot2中,我使用"panel.grid.major = theme_line(colour =" black,size = 0.2,linetype = 2)"来获得虚线圆,如下所示: 因此,我的问题是如何使轴标签(180、135、90,.....)位于圆之外,因为文本与圆线合并了.

You will find the x axis is out of the most_out circle. In ggplot2, I use "panel.grid.major = theme_line(colour = "black", size = 0.2, linetype=2)" to get the dashed circle, just as below: So my question is how to make the axis label (180, 135, 90, .....) outside of the circle, because the text are merge with the circular lines.

我尝试使用调整"或调整"来调整文本和轴之间的距离.但这是行不通的. 那么您对这个问题有一些想法吗? 首先谢谢!!!

I try to use "hjust" or "vjust" to adjust the distance between text and axis. But it does not work. So do you have some ideas about this problem? Thanks first!!!!

推荐答案

您尚未提供可重现此问题的代码,因此这只是一个猜测.

You have not provided code to reproduce the problem so this will be just a guess.

我过去使用空格,尤其是\n来移动文本.也许自定义格式器可能在这里起作用.这是您编写自定义刻度标记标签格式化程序.

I've used whitespace, \n in particular, to move text "away" in the past. Perhaps a custom formatter might work here. Here is how you can write a custom tick mark label formatter.

如果失败,则始终可以隐藏轴标签,并使用geom_text通过添加另一层来自己绘制轴标签.

If this fails, you can always hide the axis labels and paint them yourself using geom_text by adding another layer.

希望这会有所帮助. @hadley的 rel ="nofollow noreferrer">关于ggplot2的书很好,作者:道路.

Hope this helps. @hadley's book on ggplot2 is very good, by the way.

这篇关于ggplot2极坐标轴标签位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆