unity3d 可视化编程

In the last blog, we have learned how to create Dynamic Maps Using ggplot2. In this article, we will explore more into the 3D visualization in R programming language by using the plot3d package.

在上一个博客中,我们学习了如何创建 使用ggplot2使用动态地图 。 在本文中,我们将使用plot3d包对R编程语言中的3D可视化进行更多探索

The plot3d package can be used to generate stunning 3-D plots in R. It can generate an interesting array of plots, but in this recipe, we will focus on creating 3-D scatterplots. These arise in situations where we have three variables, and we want to plot the triplets of values on the xyz space.

plot3d包可用于在R中生成令人惊叹的3-D图。它可以生成有趣的图阵列,但是在本食谱中,我们将重点介绍创建3-D散点图。 这些出现在我们有三个变量的情况下,我们想在xyz空间上绘制三元组值。

We will use a specific dataset to plot them into fancy plots using the plot3d package. The following steps are implemented to create 3D visualization in R.

我们将使用plot3d包使用特定的数据集将它们绘制成精美的图。 执行以下步骤以在R中创建3D可视化 。

Step 1: Install the required packages which are needed for 3D visualization in R.

步骤1:在R中安装3D可视化所需的必需软件包。

> install.packages("rgl")Installing package into ‘C:/Users/admin/Documents/R/win-library/3.6’(as ‘lib’ is unspecified)trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/rgl_0.100.30.zip'Content type 'application/zip' length 4253430 bytes (4.1 MB)downloaded 4.1 MB

package ‘rgl’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in   C:\Users\admin\AppData\Local\Temp\Rtmpymt5Jd\downloaded_packages> install.packages("plot3D")Installing package into ‘C:/Users/admin/Documents/R/win-library/3.6’(as ‘lib’ is unspecified)package ‘plot3D’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:\Users\admin\AppData\Local\Temp\Rtmpymt5Jd\downloaded_packages

Include the required libraries in the mentioned workspace.

在上述工作区中包括所需的库。

> library(plot3D)> library(rgl)

Step 2: We will use the dataset named “income.csv” which includes all the necessary parameters which are needed for understanding income rates of every employee.

步骤2:我们将使用名为“ income.csv ”的数据集,其中包括了解每个员工的收入率所需的所有必要参数。

Step 3: Analyze the data structure of the dataset with the mentioned attributes.

步骤3:使用上述属性分析数据集的数据结构。

> str(income)'data.frame':  30 obs. of  5 variables: $ names    : Factor w/ 30 levels "brady","brandy",..: 27 29 14 17 10 26 22 24 30 18 ... $ Education: num  21.6 18.3 12.1 17 19.9 ... $ Seniority: num  113 119 101 188 20 ... $ Income   : num  99.9 92.6 34.7 78.7 68 ... $ gender   : int  1 1 0 0 1 1 1 1 1 1 ...

Step 4: It is important to understand the five-point summary of data before proceeding further. Visualization requires a lookout on bivariate and univariate analysis which is clearly understood with a five-point summary of data.

步骤4:在继续进行之前,了解数据的五点摘要很重要。 可视化需要监视双变量和单变量分析,并通过五点数据摘要清楚地了解。

> summary(income)      names      Education       Seniority          Income      brady   : 1   Min.   :10.00   Min.   : 20.00   Min.   :17.61   brandy  : 1   1st Qu.:12.48   1st Qu.: 44.83   1st Qu.:36.39   brian   : 1   Median :17.03   Median : 94.48   Median :70.80   brittany: 1   Mean   :16.39   Mean   : 93.86   Mean   :62.74   bruce   : 1   3rd Qu.:19.93   3rd Qu.:133.28   3rd Qu.:85.93   charles : 1   Max.   :21.59   Max.   :187.59   Max.   :99.92   (Other) :24                                                        gender       Min.   :0.0000   1st Qu.:0.0000   Median :1.0000   Mean   :0.6333   3rd Qu.:1.0000   Max.   :1.0000

Step 5: Let us with bivariate analysis which focusses on 2-dimensional data and scatter plot is considered as an easy method to create the same.

步骤5:让我们进行专注于二维数据的双变量分析,而将散点图视为创建该变量的简便方法。

> scatter3D(x = inc$Education, y = inc$Income, z =inc$Seniority,+           colvar = inc$Income,+           pch = 16, cex = 1.5, xlab = "Education", ylab = "Income",+           zlab = "Seniority", theta = 60, d = 2,clab = c("Income"),+           colkey = list(length = 0.5, width = 0.5, cex.clab = 0.75,+                         dist = -.08, side.clab = 3)+           ,main = "Relationship Between Income , Education and Seniority")

Here, we are plotting “Education” in the x-axis, “Income” in the y-axis and the “Seniority” level in the z-axis. The distinct legends are created based on the range of income parameters. The plot is helpful to show the relationship between Income, Education, and Society.

在这里,我们在x轴上绘制“教育”,在y轴上绘制“收入”,在z轴上绘制“高级”水平。 根据收入参数范围创建不同的图例。 该图有助于显示收入,教育和社会之间的关系。

We can add more effects to the mentioned 3D plot with plane surfaces and ranges depicted in a specific order. Consider that we want to implement a linear regression model to establish the relationship between Seniority, Education and Income we can create a predictive model for the same.

我们可以使用特定顺序描绘的平面和范围为上述3D图添加更多效果。 考虑到我们要实现线性回归模型以建立资历,教育和收入之间的关系,我们可以为此创建一个预测模型。

Step 6: Create a predictive model with the help of the RGL package. RGL is the 3D real-time rendering package in the R programming language. It provides high-level functions to create an interactive graph. To create a 3D plot of linear regression, we need to create a predictive model of the same.

步骤6:借助RGL软件包创建预测模型。 RGL是R编程语言中的3D实时渲染包。 它提供了高级功能来创建交互式图形。 要创建线性回归的3D图,我们需要创建相同的预测模型。

> lmin = lm(inc$Income~inc$Education+inc$Seniority)> lmin

Call:lm(formula = inc$Income ~ inc$Education + inc$Seniority)

Coefficients:  (Intercept)  inc$Education  inc$Seniority       -50.0856         5.8956         0.1729  > est = coef(lmin)> a = est["inc$Education"]> b = est["inc$Seniority"]> c=-1> d= est["(Intercept)"]> est  (Intercept) inc$Education inc$Seniority   -50.0856387     5.8955560     0.1728555 > ainc$Education      5.895556 > binc$Seniority     0.1728555 > c[1] -1> d(Intercept)   -50.08564

Step 7: Once the required parameters for linear regression are taken into consideration, we can create an interactive graph where we plot the data points as a scattered graph and later embed the linear regression model in them.

步骤7:一旦考虑了线性回归所需的参数,我们就可以创建一个交互式图形,在其中将数据点绘制为散点图,然后将线性回归模型嵌入其中。

> plot3d(inc$Education,inc$Seniority,inc$Income, type = "s",+        col = "blue", xlab = "Education",ylab = "Income",zlab =+            "Seniority",box = FALSE)

Now we will embed the linear regression line as mentioned below:

现在,我们将嵌入线性回归线,如下所示:

planes3d(a,b,c,d, alpha = 0.5, col = "red")

Step 8: We can create a surface plot that defines the volume and intensity of the data. Following steps are implemented to create a specific plot as mentioned below:

步骤8:我们可以创建一个表面图来定义数据的数量和强度。 执行以下步骤来创建特定图,如下所述:

> inc= read.csv("income2.csv")> View(inc)> row.names(inc)= inc$names> inc            names Education Seniority   Income gendertim           tim  21.58621 113.10345 99.91717      1tom           tom  18.27586 119.31034 92.57913      1kim           kim  12.06897 100.68966 34.67873      0mary         mary  17.03448 187.58621 78.70281      0hary         hary  19.93103  20.00000 68.00992      1thomas     thomas  18.27586  26.20690 71.50449      1peter       peter  19.93103 150.34483 87.97047      1romeo       romeo  21.17241  82.06897 79.81103      1wald         wald  20.34483  88.27586 90.00633      1matt         matt  10.00000 113.10345 45.65553      1pam           pam  13.72414  51.03448 31.91381      0pamela     pamela  18.68966 144.13793 96.28300      0larry       larry  11.65517  20.00000 27.98250      1karl         karl  16.62069  94.48276 66.60179      1brian       brian  10.00000 187.58621 41.53199      1dan           dan  20.34483  94.48276 89.00070      1sim           sim  14.13793  20.00000 28.81630      0kristin   kristin  16.62069  44.82759 57.68169      0chiu         chiu  16.62069 175.17241 70.10510      1bruce       bruce  20.34483 187.58621 98.83401      1brady       brady  18.27586 100.68966 74.70470      1brandy     brandy  14.55172 137.93103 53.53211      0charles   charles  17.44828  94.48276 72.07892      1timothy   timothy  10.41379  32.41379 18.57067      0jerry       jerry  21.58621  20.00000 78.80578      1garry       garry  11.24138  44.82759 21.38856      1jena         jena  19.93103 168.96552 90.81404      0ram           ram  11.65517  57.24138 22.63616      1brittany brittany  12.06897  32.41379 17.61359      0milly       milly  17.03448 106.89655 74.61096      0

Here, we convert the dataset into a separate vector and we also created the index based on the names of candidates. Text3d is the function that adds text to the plane surface. The text represents actual data representation. As we converted the row names with names of candidates, it becomes easy to display text in the 3D plot.

在这里,我们将数据集转换为单独的向量,并且还基于候选名称创建了索引。 Text3d是将文本添加到平面的功能。 文本表示实际数据表示。 当我们用候选名称转换行名称时,在3D图中显示文本变得很容易。

> text3D(x = inc$Education, y = inc$Income, z =inc$Seniority,+        colvar = inc$Income,labels= row.names(inc),+        pch = 16, cex = 0.8, xlab = "Education", ylab = "Income",+        zlab = "Seniority", theta = 60, d = 2,clab = c("Income"),+        colkey = list(length = 0.5, width = 0.5, cex.clab = 0.75,+                      dist = -.08, side.clab = 3)+        ,bty = "g")

Step 9: We can convert the values in proper labels with distinct colors. This helps to visualize the 3D plot more easily and distinctly with a specific color range.

步骤9:我们可以将值转换为具有不同颜色的适当标签。 这有助于在特定颜色范围内更轻松,更清晰地可视化3D图。

> text3D(x = inc$Education, y = inc$Income, z =inc$Seniority,+        colvar= inc$gender,col = c("red","black"),labels= row.names(inc),+        pch = 16, cex = 0.8,xlab = "Education", ylab = "Income",+        zlab = "Seniority", theta = 60, d = 2,clab = c("Income"),+        bty = "g", colkey = FALSE)> legend("topright", fill = c("red", "black"), legend=+            c("Female","Male"), bty = "n")

等高线图 (Contour Plots)

Contour plots visually represent the intensity of the plot. The color and graphical representation help in the visual analysis of data.

等高线图直观地表示了该图的强度。 颜色和图形表示有助于数据的可视化分析。

> x = y = seq(-3,3, length.out = 10)> x [1] -3.0000000 -2.3333333 -1.6666667 -1.0000000 -0.3333333  0.3333333 [7]  1.0000000  1.6666667  2.3333333  3.0000000> y [1] -3.0000000 -2.3333333 -1.6666667 -1.0000000 -0.3333333  0.3333333 [7]  1.0000000  1.6666667  2.3333333  3.0000000> f = function(x,y){ z= (y^2-x^2)}> m = outer(x,y,f)> > image2D(m)> image2D(m, contour = TRUE)> > persp3D(z = m, contour = TRUE)> persp3D(z = volcano, contour = TRUE)> > library(rgl)> c = terrain.colors(5)> persp3d(z = volcano, contour = TRUE, col = c)

The output of the contour plot is mentioned below:

等高线图的输出如下所述:

The interactive 3d plot is mentioned below:

交互式3d图如下所示:

We can also create a plot with an animation feature which increases the interactive rate. For this, it is important to install an “animation” package which helps in creating the plots as desired.

我们还可以创建带有动画功能的绘图,以提高交互速率。 为此,重要的是安装一个“动画”程序包,该程序包可以帮助创建所需的绘图。

> install.packages("plotrix")Installing package into ‘C:/Users/admin/Documents/R/win-library/3.6’(as ‘lib’ is unspecified)trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/plotrix_3.7-7.zip'Content type 'application/zip' length 1132324 bytes (1.1 MB)downloaded 1.1 MB

package ‘plotrix’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:\Users\admin\AppData\Local\Temp\RtmpSCUS7b\downloaded_packages> > install.packages("animation")Installing package into ‘C:/Users/admin/Documents/R/win-library/3.6’(as ‘lib’ is unspecified)trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/animation_2.6.zip'Content type 'application/zip' length 548202 bytes (535 KB)downloaded 535 KB

package ‘animation’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in    C:\Users\admin\AppData\Local\Temp\RtmpSCUS7b\downloaded_packages> > library(plot3D)> library(plotrix)

Attaching package: ‘plotrix’

The following object is masked from ‘package:rgl’:

    mtext3d

> library(animation)> > x = y = seq(0,2*pi, length.out = 100)> > z = mesh(x,y)> u = z$x> v = z$y> > m= (sin(u)*sin(2*v)/2)> n = (sin(2*u)*cos(v)*cos(v))> o = (cos(2*u)*cos(v)*cos(v))> > surf3D(m, n,o, colvar = o, border = "black",colkey = FALSE,box = TRUE)> > surf3D(m, n,o, colvar = o, border = "black",colkey = TRUE, box = TRUE,theta = 60)> > surf3D(m, n,o, colvar = o, border = "black",colkey = TRUE,box = TRUE,theta = 100)> > library("animation")> saveHTML({+     for (i in 1:100 ){+         x = y = seq(0,2*pi, length.out = 100)+         z = mesh(x,y)+         u = z$x+         v = z$y+         m= (sin(u)*sin(2*v)/2)+         n = (sin(2*u)*cos(v)*cos(v))+         o = (cos(2*u)*cos(v)*cos(v))+         surf3D(m, n,o, colvar = o, border = "black",colkey = FALSE,+                theta = i, box = TRUE)+     }+ },interval = 0.1, ani.width = 500, ani.height = 1000)

The ranges of the graphs are depicted below:

图的范围如下所示:

The file is saved with .html extension and represents the graphical animation of the values in three co-ordinates.

该文件以.html扩展名保存,并以三个坐标表示值的图形动画。

So, this was all about 3D visualization in R programming!

因此,这一切都与R编程中的3D可视化有关!

In the next section, we will be going to learn about Data Wrangling and Visualization in R programming language.

在下一节中,我们将学习R编程语言中的数据整理和可视化

Originally published https://blog.eduonix.com on March 27, 2020

最初 2020 3月27日发布 https://blog.eduonix.com

翻译自: https://medium.com/eduonix/r-programming-series-3d-visualization-in-r-3f9280d7ddb4

unity3d 可视化编程

http://www.taodudu.cc/news/show-994934.html

相关文章:

  • python 数据科学 包_什么时候应该使用哪个Python数据科学软件包?
  • 熊猫tv新功能介绍_您应该知道的4种熊猫绘图功能
  • vs显示堆栈数据分析_什么是“数据分析堆栈”?
  • 广告投手_测量投手隐藏自己的音高的程度
  • python bokeh_提升视觉效果:使用Python和Bokeh制作交互式地图
  • nosql_探索NoSQL系列
  • python中api_通过Python中的API查找相关的工作技能
  • 欺诈行为识别_使用R(编程)识别欺诈性的招聘广告
  • nlp gpt论文_GPT-3:NLP镇的最新动态
  • 基于plotly数据可视化_[Plotly + Datashader]可视化大型地理空间数据集
  • 划痕实验 迁移面积自动统计_从Jupyter迁移到合作实验室
  • 数据开放 数据集_除开放式清洗之外:叙述是开放数据门户的未来吗?
  • 它们是什么以及为什么我们不需要它们
  • 机器学习 啤酒数据集_啤酒数据集上的神经网络
  • nasa数据库cm1数据集_获取下一个地理项目的NASA数据
  • r语言处理数据集编码_在强调编码语言或工具之前,请学习这3个基本数据概念
  • 数据迁移测试_自动化数据迁移测试
  • 使用TensorFlow概率预测航空乘客人数
  • 程序员 sql面试_非程序员SQL使用指南
  • r a/b 测试_R中的A / B测试
  • 工作10年厌倦写代码_厌倦了数据质量讨论?
  • 最佳子集aic选择_AutoML的起源:最佳子集选择
  • 管道过滤模式 大数据_大数据管道配方
  • 用户体验可视化指南pdf_R中增强可视化的初学者指南
  • sql横着连接起来sql_SQL联接的简要介绍(到目前为止)
  • 如何击败Python的问题
  • 数据冒险控制冒险_劳动生产率和其他冒险
  • knn 邻居数量k的选取_选择K个最近的邻居
  • 什么样的代码是好代码_什么是好代码?
  • 在Python中使用Twitter Rest API批量搜索和下载推文

unity3d 可视化编程_R编程系列:R中的3D可视化相关推荐

  1. python数据可视化库_python和r中用于数据可视化的前9个库

    python数据可视化库 In the rapidly growing world of today, when technology is expanding at a rate like neve ...

  2. 如何在 R 中创建 3D 绘图(附示例)

    示例 1:基本 3D 绘图 下面的代码展示了如何创建一个基本的 3D 绘图: #define x and y x <- -10:10 y <- -10:10#define function ...

  3. r语言中进行数据可视化_R中的数据可视化

    r语言中进行数据可视化 R programming was developed in 1993 for making graphs and producing statistical results. ...

  4. 3D可视化色彩设计大揭秘

    3D可视化,是目前非常热门的方向.所谓"文不如表,表不如图",3D可视化具有丰富的展示形式和效果,美观和设计感也成了当下3D可视化行业越来越重视的部分. 在3D可视化场景中利用颜色 ...

  5. 数字孪生与3D可视化

    数字孪生(Digital Twin)和3D可视化(3D Visualization)是两个不同领域的概念,但是它们之间存在紧密的联系.数字孪生是指将实物对象(比如机器.建筑.城市等)的数字模型(不一定 ...

  6. 行业研究报告-全球与中国室内设计师3D可视化软件市场现状及未来发展趋势

    报告摘要 本文研究全球及中国市场室内设计师3D可视化软件现状及未来发展趋势,侧重分析全球及中国市场的主要企业,同时对比北美.欧洲.日本.中国.东南亚.印度等地区的现状及未来发展趋势. 2019年全球室 ...

  7. 数字孪生-智慧园区3D可视化管理平台

          自主研发的基于HTML5的3D图形渲染引擎+mmsDT开发平台,为Web可视化提供了丰富的展现形式和视觉效果.木棉树软件聚焦工业数字孪生的生产管控.智慧城市的监控运维等可视化应用领域,产品 ...

  8. 数据中心 3D 可视化,动环、资产、容量管理一屏搞定

    在"双碳"战略背景下,数据中心作为高耗能产业,必然在清洁.集约.循环的绿色发展道路上阔步前行.各企业正顺应碳中和大势,应用数字化技术,构建先进实用.自主可控.完备可靠的数据中心 3 ...

  9. 市场调研报告-全球与中国设计用3D可视化软件市场现状及未来发展趋势

    2021-2027全球与中国设计用3D可视化软件市场现状及未来发展趋势 [纸版价格]:RMB 18900 [电子版(PDF)价格]:RMB 18900 [企业版]:RMB 37800 [报告篇幅]:1 ...

最新文章

  1. 用python的turtle画圆-(python海龟绘图怎么增加每次画圆的半径)
  2. leetcode算法题--大礼包
  3. 任务调度之Quartz1
  4. Python基于nginx访问日志并统计IP访问量
  5. leetcode刷题 162.寻找峰值
  6. python input函数无法输入字符串_Python手把手教程之用户输入input函数
  7. NSTimer注意内存泄露(真该死)
  8. 麦森数(洛谷-P1045)
  9. html自动切换body背景,html中怎么用body元素设置背景颜色
  10. Spring Boot 文件上传功能实现与简单示例
  11. 离线安装.net4.032位_怎样在断网的情况下安装IE11
  12. 2022年计算机一级考试网络安全素质教育模拟试题及答案
  13. Spring Configuration Check ----Unmapped Spring configuration files found.
  14. 华为手机默认浏览器打开应用宝链接直接启动应用问题解决
  15. 计算机windows10怎么找word,Win10 word路径在哪?Win10如何修改word路径
  16. 【NOI2012】骑行川藏
  17. 区分Internet和Local数据流的Qos实现
  18. 集体过冬,Hyper-V为企业省钱
  19. 论文审稿意见太奇葩?NeurIPS 2021:把它曝光出来给人看
  20. 红外图像处理-基于场景的非均匀矫正

热门文章

  1. hwt字体转换ttf_五分钟教你弄懂了字体反爬是个啥
  2. 关于cp命令中拷贝所有的写法
  3. CentOS 7 安装nginx
  4. linux网络编程(一)网络基础传输知识
  5. 【算法】学习笔记(0):算法初探(逻辑抽象 + 示例 + 代码实现)
  6. Leetcode 7. 整数反转
  7. 国内互联网公司算法机器学习岗(阿里星)面试总结
  8. Linux中强大的输入输出重定向和管道
  9. CSS3--5.颜色属性
  10. scrapy从安装到爬取煎蛋网图片