简体   繁体   English

在X轴上添加标签

[英]Add labels on X-axis

Simple question. 简单的问题。

I'd like to add custom characters to label the X-axis in R Histogram. 我想添加自定义字符来标记R直方图中的X轴。

As can be seen on the image belov, the only labeling for the units is 0,50,100 but I'd like to have 0,5,10,15,etc (or 0:5,5:10,10:15,15:20,etc written perpendicular to the axis) 从图像belov可以看出,单位的唯一标签是0,50,100,但我想要0,5,10,15等(或0:5,5:10,10:15,15) :20等垂直于轴写的)

我是多么喜欢它的插图

Is there a variable I've overlooked in customizing the addition of labels or do i need to use another lib than Hist, perhaps ggplot2? 有没有我在定制添加标签时忽略的变量,还是我需要使用另一个lib而不是Hist,也许是ggplot2?

Replying to someone who might be making a histogram without using ggplot2: 在不使用ggplot2的情况下回复可能正在制作直方图的人:

set.seed(0)
hist(runif(250, 0, 100), cex.axis = 0.6, xaxt = "n",
     col = rgb(0,0, 0.8, 0.35), border = FALSE, xlab = "x", main = "")

myseq <- as.character(seq(0,100, by = 5))
axis(1, at = myseq, labels = myseq, cex.axis = 0.6)
title(main = "Using of the graphics package", xlab = "x")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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