[英]In R rgl, how to choose the position of tick marks in plot3d?
In R, 在R中
library(rgl)
m <- matrix(rnorm(300),100,3)
par3d(ignoreExtent=F)
plot3d(m,box=T,axes=F,xlab='',ylab='',zlab='')
axes3d(labels=F,tick=F,box=F)
gr <- grid3d('z')
par3d(ignoreExtent=T)
plot3d(cbind(m[,1:2],rgl.attrib(gr[1],'vertices')[1,3]),col='gray',add=T)
still prints the ticks with numbers: 仍然打印带有数字的刻度:
Shouldn't tick=F
parameter in axes3d()
get rid of the tick marks and the numbers? axes3d()
tick=F
参数是否应该摆脱刻度线和数字?
I want to add the x and y axes at the bottom of the graph, not at the top. 我想将x和y轴添加到图表的底部,而不是顶部。 Also, when I add them using
axis3d()
, the ticks aren't orthogonal anymore, but inclined in 45 degrees relative to their plane, which I think is ugly. 另外,当我使用
axis3d()
添加它们时,刻度线不再正交,而是相对于其平面倾斜45度,我认为这很丑陋。
par3d(ignoreExtent=F)
plot3d(m,box=T,axes=F,xlab='',ylab='',zlab='')
box3d()
axis3d('x--',labels=T,tick=T)
axis3d('y+-',labels=T,tick=T)
axis3d('z++',labels=T,tick=T)
gr <- grid3d('z')
par3d(ignoreExtent=T)
plot3d(cbind(m[,1:2],rgl.attrib(gr[1],'vertices')[1,3]),col='gray',add=T)
If I have to go this second way, how to get rid of the front lines of the box? 如果我必须走第二条路,如何摆脱包装箱的前线? Or is there another way to print the default tick marks (orthogonal) in the desired position?
还是有另一种方法可以在所需位置打印默认刻度线(正交)?
Axes in rgl
are somewhat confusing and not very flexible. rgl
中的轴有些令人困惑并且不够灵活。 First, there are two different kinds: those drawn by axis3d
, and those drawn with rgl.bbox
. 首先,有两种不同的类型:由
axis3d
绘制的axis3d
和由axis3d
绘制的rgl.bbox
。 Only the first type pays attention to the tick
argument, and your first example used the second type. 只有第一种类型会注意
tick
参数,而第一个示例使用第二种类型。
You can remove the ticks in the rgl.bbox
axes by setting marklen = 0, marklen.rel = FALSE
, but this has the unfortunate effect of putting the numbers right on the box. 您可以通过设置
marklen = 0, marklen.rel = FALSE
来消除rgl.bbox
轴上的刻度线,但是不幸的是,将数字正确地放在方框上。 There isn't a separate parameter to control placement of the numbers independent of tickmark length. 没有单独的参数来控制数字的位置,而与刻度线的长度无关。 If you don't want numbers at all, use
xlen = 0, ylen = 0, zlen = 0
. 如果根本不需要数字,请使用
xlen = 0, ylen = 0, zlen = 0
。
The axis3d
axes are also not very flexible. axis3d
轴也不是很灵活。 If you want to change their orientation, you'll need to modify that function. 如果要更改其方向,则需要修改该功能。 The
mpos
array holds the coordinates of each tick; mpos
数组保存每个刻度的坐标; change it to make the ticks point the way you want. 更改它以使刻度线指向您想要的方式。
Regarding the box: it's fixed if you use box3d()
to draw it. 关于盒子:如果使用
box3d()
绘制它,则该问题已修复。 If you want the rgl.bbox
style, you'll have to use that function. 如果要使用
rgl.bbox
样式,则必须使用该功能。 You could also use segments3d()
and mtext3d()
to construct your own axes, but they won't move around like the rgl.bbox
axes. 您也可以使用
mtext3d()
segments3d()
和mtext3d()
来构造自己的轴,但是它们不会像rgl.bbox
轴那样rgl.bbox
移动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.