R:绘图轴显示值大于原始数据 [英] R: Plot Axis Display Values Larger than the Original Data

查看:49
本文介绍了R:绘图轴显示值大于原始数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R编程语言.我在这里关注有关数据可视化的教程:

如在此所见,在该3D图上有一个点"y = 97".看到原始数据帧"d"中的值都没有怎么变化,我不确定这是怎么可能的.都接近97.我通过查看原始数据帧"d"中每个变量的单独分布来确保这一点:

  #plot各个密度plot(密度(d $ a),main =密度图",col =红色")行(密度(d $ b),col =蓝色")线(密度(d $ c),col =绿色")图例("topleft",c("a","b","c")),text.col = c(红色",蓝色",绿色")) 

如在此所见,来自原始数据帧"d"的变量(a,b,c)都不存在.具有接近97的任何值.

因此,我的问题是:有人可以解释点(x = 0,y = 97,z = 25.326)出现在此3D图上的可能性如何吗?

谢谢

解决方案

我不确定这是否可以解决问题-但使用与以前的stackoverflow帖子相同的逻辑:

现在,看起来在此可视化图中看到的所有值都包含在原始数据框中.

但是,我仍然不确定这两个图之间的基本(和数学)差异是什么

我很好奇,看看别人怎么说.

谢谢

I am using the R programming language. I am following a tutorial on data visualization over here: https://plotly.com/r/3d-surface-plots/

I created my own data and made a 3D plot:

library(plotly)

set.seed(123)

#generate data
a = rnorm(100,10,10)
b = rnorm(100,5,5)
c = rnorm(100,5,10)
d = data.frame(a,b,c)

#3d plot
fig <- plot_ly(z = ~as.matrix(d))
fig <- fig %>% add_surface()

#view plot
fig

As seen here, there is a point on this 3D plot where "y = 97". I am not sure how this is possible, seeing how none of the values within the original data frame "d" are anywhere close to 97. I made sure of this by looking at the individual distributions of each variable in the original data frame "d":

#plot individual densities 

plot(density(d$a), main = "density plots", col = "red")
lines(density(d$b), col = "blue")
lines(density(d$c), col = "green")

legend( "topleft", c("a", "b", "c"), 
text.col=c("red", "blue", "green") )

As seen here, none of the variables (a,b,c) from the original data frame "d" have any values that are close to 97.

Thus, my question: can someone please explain how is it possible that the point (x = 0 , y = 97, z =25.326) appears on this 3D plot?

Thanks

解决方案

I am not sure if this will resolve the problem - but using the same logic from this previous stackoverflow post: 3D Surface with Plot_ly in r, with x,y,z coordinates

library(plotly)
set.seed(123)

#generate data
a = rnorm(100,10,10)
b = rnorm(100,5,5)
c = rnorm(100,5,10)
d = data.frame(a,b,c)


data = d

plot_ly() %>% 
  add_trace(data = data,  x=data$a, y=data$b, z=data$c, type="mesh3d" ) 

Now, it appears that all values seen in this visual plot are contained in the original data frame.

However, I am still not sure what is the fundamental (and mathematical) difference between both of these plots:

I am curious to see what others have to say.

Thanks

这篇关于R:绘图轴显示值大于原始数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆