R - ggplot2将x轴值更改为非日志值 [英] R - ggplot2 change x-axis values to non-log values

查看:302
本文介绍了R - ggplot2将x轴值更改为非日志值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我绘制了一些付款分配信息,并在将它缩放到log-normal(base-e)后汇总了数据。直方图效果很好,但我想修改x轴以显示非日志等值。



我的当前轴显示[0:2.5:10]值
另外,我希望看到exp(2.5),exp(5),等等。



有关如何完成此操作的任何建议?任何我可以添加到我的绘图语句来缩放X轴值?也许有更好的方法 - 想法?



当前的代码:

  ggplot(plotData,aes_string(pay,fill = pt))+ geom_histogram(bins = 50)+ facet_wrap(〜M_P)



已回答...最终情节:

解决方案

不知道这是否正是你所追求的,但你可以改变x轴的文本



这里不包含:

  ggplot(data = cars)+ geom_histogram(aes(x = speed),binwidth = 1)

与:

  ggpl ot(data = cars)+ geom_histogram(aes(x = speed),binwidth = 1)+ 
scale_x_continuous(breaks = c(5,10,15,20,25),labels = c(exp(5) ,exp(10)exp(15)exp(20)exp(25))

I am plotting some payment distribution information and I aggregated the data after scaling it to log-normal (base-e). The histograms turn out great but I want to modify the x-axis to display the non-log equivalents.

My current axis displays [0:2.5:10] values Alternatively, I would like to see values for exp(2.5), exp(5), etc.

Any suggestions on how to accomplish this? Anything I can add to my plotting statement to scale the x-axis values? Maybe there's a better approach - thoughts?

Current code:

ggplot(plotData, aes_string(pay, fill = pt)) + geom_histogram(bins = 50) + facet_wrap(~M_P)

Answered...Final plot:

解决方案

Not sure if this is exactly what you are after but you can change the text of the x axis labels to whatever you want using scale_x_continuous.

Here's without:

ggplot(data = cars) + geom_histogram(aes(x = speed), binwidth = 1)

Here's with:

ggplot(data = cars) + geom_histogram(aes(x = speed), binwidth = 1) +
  scale_x_continuous(breaks=c(5,10,15,20,25), labels=c(exp(5), exp(10), exp(15), exp(20), exp(25)))

这篇关于R - ggplot2将x轴值更改为非日志值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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