简体   繁体   English

y轴上的Y轴标签仅在R中使用xyplot

[英]axis labels on y-axis only using xyplot in R

Relatively new to site and r so please forgive any protocols I may not adhere to. 该网站相对较新,因此请原谅我可能不遵守的所有协议。

I am producing a plot with xyplot. 我正在用xyplot制作一个情节。 My code 我的密码

library(lattice)

height <- c(1,3,5)
mass <- c(10, 12, 14)

d <- data.frame (height,mass)

xyplot(height ~ mass, type = 'a', scales = list(alternating = 1, tck = c(1,0)))

and I get this 我明白了

情节的图像在这里

My problem is that I cannot remove the labels from the x-axis so only the y-axis ticks are labelled. 我的问题是我无法从x轴上移除标签,因此仅标记了y轴刻度。 This is so I can stack a number of plots with data.arrange. 这样一来,我就可以使用data.arrange堆叠多个图。 I have looked here and on other places online and found some answers but I clearly do not understand the code because I still cannot do it. 我已经在这里和其他网上地方找到了答案,但是我显然不理解该代码,因为我仍然无法做到。 I have tried removing the axes and rebuilding with "scales" to no success. 我尝试过删除轴并使用“比例”进行重建没有成功。

Can someone please assist me with this? 有人可以帮我吗?

Regards Aaron 问候亚伦

Inside the scales argument you can add a list for the attributes of the x-axis and set labels=NULL . scales参数内,您可以为x轴的属性添加一个列表,并设置labels=NULL For additional options, see the scales section in the help for xyplot . 有关其他选项,请参见xyplot帮助中的“ scales部分。 I've also removed the x-axis title since you probably won't want that repeated for each graph either: 我还删除了x轴标题,因为您可能也不想在每个图形上都重复此操作:

xyplot(height ~ mass, type ='a', xlab="", 
       scales=list(alternating=1, tck=c(1,0), x=list(labels=NULL)))  

在此处输入图片说明

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

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