R中断轴代码错误(plotrix gap.plot)

时间:2022-05-18 14:58:00

When I try to break axis of a plot I always get an error. I use plotrix pkg.

当我试图打破一个情节的轴时,我总是得到一个错误。我使用plotrix pkg。

My code so far:

我的代码到目前为止:

xlim <- c(0,1)
ylim <- c(0,1)
gap.plot(evcent(USAN_g_num)$vector, betweenness(USAN_g_num, normalized=T), gap=c(0.4,0.6),gap.axis="y", xtics=c(0,0.3,0.7,1) ,xlim='xlim', ylim='ylim')

I get this error:

我收到此错误:

Error in rangexy[2] - rangexy[1] : 
  non-numeric argument to binary operator

Actually I think that I don't really need xlim and ylim. However I get an error that says me that xlim is missing if I don't use it.

其实我觉得我真的不需要xlim和ylim。但是我收到一个错误,告诉我如果我不使用它,xlim就会丢失。

Why I need a gap in Y-axis: My data ranges from 0 to 1 on both, x and y axis. On y axis I got an outlier. Therefore I have no datapoint between 0.4 and 0.6 on Y axis. Therefore I would like to cut this section out. What did I do wrong with my code? Thank for any help & sorry for this - maybe - beginner question.

为什么我需要在Y轴上有间隙:我的数据在x和y轴上的范围从0到1。在y轴上,我有一个异常值。因此,我在Y轴上没有0.4到0.6之间的数据点。因此,我想删除这一部分。我的代码怎么办?感谢任何帮助和抱歉 - 也许 - 初学者问题。

2 个解决方案

#1


1  

Unfortunately your code is not reproducible because you do not provide USAN_g_num.

遗憾的是,由于您未提供USAN_g_num,因此您的代码无法重现。

But try:

xlim=xlim, ylim=ylim

in your call to gap.plot instead of xlim='xlim' and ylim='ylim'.

在你对gap.plot的调用中,而不是xlim ='xlim'和ylim ='ylim'。

#2


0  

Is there a reason that you are defining xlim and ylim outside of the call to gap.plot?

你是否有理由在调用gap.plot之外定义xlim和ylim?

Otherwise, your error is due to passing a character string 'xlim' to the argument rather than a numerical range. Try the following, which will have the added benefit of shortening your code and not storing xlim and ylim as global variables:

否则,您的错误是由于将字符串'xlim'传递给参数而不是数字范围。尝试以下操作,这将带来缩短代码的额外好处,而不是将xlim和ylim存储为全局变量:

gap.plot(evcent(USAN_g_num)$vector, betweenness(USAN_g_num, normalized=T), gap=c(0.4,0.6),gap.axis="y", xtics=c(0,0.3,0.7,1) ,xlim=c(0,1), ylim=c(0,1)

gap.plot(evcent(USAN_g_num)$ vector,介于(USAN_g_num,normalized = T),gap = c(0.4,0.6),gap.axis =“y”,xtics = c(0,0.3,0.7,1), xlim = c(0,1),ylim = c(0,1)

#1


1  

Unfortunately your code is not reproducible because you do not provide USAN_g_num.

遗憾的是,由于您未提供USAN_g_num,因此您的代码无法重现。

But try:

xlim=xlim, ylim=ylim

in your call to gap.plot instead of xlim='xlim' and ylim='ylim'.

在你对gap.plot的调用中,而不是xlim ='xlim'和ylim ='ylim'。

#2


0  

Is there a reason that you are defining xlim and ylim outside of the call to gap.plot?

你是否有理由在调用gap.plot之外定义xlim和ylim?

Otherwise, your error is due to passing a character string 'xlim' to the argument rather than a numerical range. Try the following, which will have the added benefit of shortening your code and not storing xlim and ylim as global variables:

否则,您的错误是由于将字符串'xlim'传递给参数而不是数字范围。尝试以下操作,这将带来缩短代码的额外好处,而不是将xlim和ylim存储为全局变量:

gap.plot(evcent(USAN_g_num)$vector, betweenness(USAN_g_num, normalized=T), gap=c(0.4,0.6),gap.axis="y", xtics=c(0,0.3,0.7,1) ,xlim=c(0,1), ylim=c(0,1)

gap.plot(evcent(USAN_g_num)$ vector,介于(USAN_g_num,normalized = T),gap = c(0.4,0.6),gap.axis =“y”,xtics = c(0,0.3,0.7,1), xlim = c(0,1),ylim = c(0,1)