[英]How to label each bar on X axis using histogram in R in PowerBi
I'm using R and PowerBI. 我正在使用R和PowerBI。 I use
hist()
function for histogram and it does the job. 我将
hist()
函数用于直方图,即可完成工作。 I'm not able to put labels for each bar on x axis. 我无法在x轴上为每个条形贴标签。 The closes parameter I found is called
labels = TRUE
我发现的closes参数称为
labels = TRUE
I want each bar to have a value that is increment of 10,000 in this case. 在这种情况下,我希望每个小节的值都是10,000。
assign the histogram to a variable and then obtain the values to plot and co-ordinates to plot at from that variable. 将直方图分配给变量,然后从该变量获取要绘制的值和要绘制的坐标。 Set
xaxt = "n"
to supress x-axis at first and then use axis
to add the desired x-axis. 首先将
xaxt = "n"
设置为xaxt = "n"
x轴,然后使用axis
添加所需的x轴。 Read more at ?par
了解更多信息
?par
set.seed(42)
x = rnorm(250)
h = hist(x, xaxt = "n")
text(x = h$mids, y = h$counts, labels = h$counts, pos = 3)
axis(side = 1, at = h$mids, seq_along(h$mids)*10000, las = 2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.