使用R包barplot3d绘制3D条形图-2020-07-04Sat
## 1.设置当前工作目录
setwd("./barplot3d/")
## 2.安装和导入R包
# install.packages("barplot3d")
library(barplot3d)
## 3.R包简介
### 3.1 Description
help(package="barplot3d")
# Package: barplot3d
# Type: Package
# Title: Create 3D Barplots
# Version: 1.0.1
# Authors@R: person("Christopher", "Wardell", email="r@cpwardell.com", role=c("aut","cre"))
# Description: Creates 3D barplots. Includes a function for sequence context plots used in DNA sequencing analysis.
# License: Apache License 2.0 | file LICENSE
# Encoding: UTF-8
# LazyData: true
# Imports: rgl
# RoxygenNote: 6.1.1
# Suggests: knitr, rmarkdown
# VignetteBuilder: knitr
# NeedsCompilation: no
# Packaged: 2019-11-05 03:21:48 UTC; cpw
# Author: Christopher Wardell [aut, cre]
# Maintainer: Christopher Wardell <r@cpwardell.com>
# Repository: CRAN
# Date/Publication: 2019-11-06 15:40:07 UTC
# Built: R 4.0.2; ; 2020-06-27 22:17:10 UTC; windows
### 3.2 Package structure
ls(package:barplot3d)
# [1] "bar3d" "barplot3d" "legoplot3d"
################
## 4.开始测试 ##
################
### 4.1 Two example plots
#### 4.1.1 Something very simple
## Load packages
library(rgl)
## Make a very simple 3D barplot using mostly defaults
?barplot3d
# Adds a 3D bar plot to the current RGL scene
barplot3d(rows=1,cols=5,z=1:5,theta=10,phi=10,alpha = 0.5)
# 参数测试
#@ 参数:alpha透明度调节
barplot3d(rows=1,cols=5,z=1:5,theta=10,phi=10,alpha = 0.9, topcolors = "#078E53")
#@ 参数:topcolors条形图上顶颜色调节
barplot3d(rows=1,cols=5,z=1:5,theta=10,phi=10,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE")
#@ 参数:linecolors条形图的边线颜色调整
barplot3d(rows=1,cols=5,z=1:5,theta=10,phi=10,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000")
#@ 参数:theta水平调整3d条形图的角度
barplot3d(rows=1,cols=5,z=1:5,theta=50,phi=10,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000")
#@ 参数:phi垂直调整3d条形图的角度
barplot3d(rows=1,cols=5,z=1:5,theta=50,phi=50,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000")
#@ 参数:gridlines决定是否填加条形图的背景网格,T则填加,F则不填加
barplot3d(rows=1,cols=5,z=1:5,theta=50,phi=50,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000", gridlines = T)
barplot3d(rows=1,cols=5,z=1:5,theta=50,phi=50,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000", gridlines = F)
#@ 参数:xlabels, Labels for the x axis (must be a vector of names the same length as "cols" parameter).
barplot3d(rows=1,cols=5,z=1:5,theta=50,phi=50,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000", gridlines = F, xlabels = c("A", "B", "C", "D", "E"))
#@ 参数:ylabels, Labels for the y axis (must be a vector of names the same length as "rows" parameter).
barplot3d(rows=1,cols=5,z=1:5,theta=50,phi=50,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000", gridlines = F, xlabels = c("A", "B", "C", "D", "E"), ylabels = "value")
#@ 参数:zlabels, Labels for the z axis; add numeric scale to the vertical dimension of the plot (TRUE or FALSE).
barplot3d(rows=1,cols=5,z=1:5,theta=50,phi=50,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000", gridlines = F, xlabels = c("A", "B", "C", "D", "E"), ylabels = "value", zlabels = F)
#@ 参数:xsub
barplot3d(rows=1,cols=5,z=1:5,theta=60,phi=10,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000", gridlines = F, xlabels = c("A", "B", "C", "D", "E"), ylabels = "value", zlabels = T, xsub = "Samples")
#@ 参数:ysub
barplot3d(rows=1,cols=5,z=1:5,theta=60,phi=10,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000", gridlines = F, xlabels = c("A", "B", "C", "D", "E"), ylabels = "value", zlabels = T, xsub = "Samples", ysub = "Molecular Weight[KDa]")
#@ 参数:zsub
barplot3d(rows=1,cols=5,z=1:5,theta=60,phi=10,alpha = 0.5, topcolors = "#078E53", sidecolors = "#00B2EE", linecolors = "#EE0000", gridlines = F, xlabels = c("A", "B", "C", "D", "E"), ylabels = "value", zlabels = T, xsub = "Samples", ysub = "Molecular Weight[KDa]", zsub = "Just Number")
#### 4.1.2 Something more decorative
## Make a prettier 3D barplot with more advanced features
inputdata=round(rnorm(15,10,3))
barplot3d(rows=3,cols=5,z=inputdata,scalexy=5,alpha=0.4,theta=30,phi=50,
topcolors=rainbow(15),xlabels = 1:5,ylabels=LETTERS[1:3],
xsub="Numbers",ysub="Letters",zsub="Count")
#@ 重新构建一个更庞大的3d条形图
big_inputdata <- round(rnorm(100, 50, 2))
barplot3d(rows=10,cols=10,z=big_inputdata,scalexy=5,alpha=0.4,theta=30,phi=50, topcolors=rainbow(100),xlabels = 1:10,ylabels=LETTERS[1:10], xsub="Numbers",ysub="Letters",zsub="Count")
### 4.3 Viewing angles, plot size and saving your plot
# “theta” rotates the viewpoint in the horizontal plane (imagine it on a rotating turntable) and can be set between 0 and 360 degrees.
# “phi” rotates the viewpoint in the vertical plane (imagine going below and above the plot) and can be set between -90 to 90 (-90 is directly below, 90 directly above).
# The 4 arguments are the position (in pixels) of the left, top, right and bottom edges of the rgl viewing window
# This code leads to a plot that is 600 pixels wide and 400 pixels tall.
par3d(windowRect=c(0,50,600,450))
# Save the current rgl view
rgl.snapshot("filename.png")
# Error in rgl.snapshot("filename.png") :
# pixmap save format not supported in this build
### 4.4 Legoplots
# Read in COSMIC signature probabilities
x=system.file("extdata", "signature_probabilities.txt", package = "barplot3d")
sigdata=read.table(x,header=TRUE,stringsAsFactors = FALSE)
# Plot signature 2 without axis labels, with Sanger colors and some transparency so we can see all bars
legoplot3d(contextdata=sigdata$Signature_2,labels=FALSE,scalexy=0.05,sixcolors="sanger",alpha=0.4)
# Plot signature 2 without axis labels, with Sanger colors and some transparency so we can see all bars
legoplot3d(contextdata=sigdata$Signature_8,labels=FALSE,scalexy=0.01,sixcolors="broad",alpha=0.4)
# Input data MUST be in this order
cat(sigdata$Somatic_mutation_type,sep="\n")
# C>A|G>T_AxA
# C>A|G>T_CxA
# C>A|G>T_GxA
# C>A|G>T_TxA
# C>A|G>T_AxC
# C>A|G>T_CxC
# C>A|G>T_GxC
# C>A|G>T_TxC
# C>A|G>T_AxG
# C>A|G>T_CxG
# C>A|G>T_GxG
# C>A|G>T_TxG
# C>A|G>T_AxT
# C>A|G>T_CxT
# C>A|G>T_GxT
# C>A|G>T_TxT
# C>G|G>C_AxA
# C>G|G>C_CxA
# C>G|G>C_GxA
# C>G|G>C_TxA
# C>G|G>C_AxC
# C>G|G>C_CxC
# C>G|G>C_GxC
# C>G|G>C_TxC
# C>G|G>C_AxG
# C>G|G>C_CxG
# C>G|G>C_GxG
# C>G|G>C_TxG
# C>G|G>C_AxT
# C>G|G>C_CxT
# C>G|G>C_GxT
# C>G|G>C_TxT
# C>T|G>A_AxA
# C>T|G>A_CxA
# C>T|G>A_GxA
# C>T|G>A_TxA
# C>T|G>A_AxC
# C>T|G>A_CxC
# C>T|G>A_GxC
# C>T|G>A_TxC
# C>T|G>A_AxG
# C>T|G>A_CxG
# C>T|G>A_GxG
# C>T|G>A_TxG
# C>T|G>A_AxT
# C>T|G>A_CxT
# C>T|G>A_GxT
# C>T|G>A_TxT
# T>A|A>T_AxA
# T>A|A>T_CxA
# T>A|A>T_GxA
# T>A|A>T_TxA
# T>A|A>T_AxC
# T>A|A>T_CxC
# T>A|A>T_GxC
# T>A|A>T_TxC
# T>A|A>T_AxG
# T>A|A>T_CxG
# T>A|A>T_GxG
# T>A|A>T_TxG
# T>A|A>T_AxT
# T>A|A>T_CxT
# T>A|A>T_GxT
# T>A|A>T_TxT
# T>C|A>G_AxA
# T>C|A>G_CxA
# T>C|A>G_GxA
# T>C|A>G_TxA
# T>C|A>G_AxC
# T>C|A>G_CxC
# T>C|A>G_GxC
# T>C|A>G_TxC
# T>C|A>G_AxG
# T>C|A>G_CxG
# T>C|A>G_GxG
# T>C|A>G_TxG
# T>C|A>G_AxT
# T>C|A>G_CxT
# T>C|A>G_GxT
# T>C|A>G_TxT
# T>G|A>C_AxA
# T>G|A>C_CxA
# T>G|A>C_GxA
# T>G|A>C_TxA
# T>G|A>C_AxC
# T>G|A>C_CxC
# T>G|A>C_GxC
# T>G|A>C_TxC
# T>G|A>C_AxG
# T>G|A>C_CxG
# T>G|A>C_GxG
# T>G|A>C_TxG
# T>G|A>C_AxT
# T>G|A>C_CxT
# T>G|A>C_GxT
# T>G|A>C_TxT
## 5.测试完成
sessionInfo()
# R version 3.6.3 (2020-02-29)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 10 x64 (build 18363)
#
# Matrix products: default
#
# locale:
# [1] LC_COLLATE=Chinese (Simplified)_China.936
# [2] LC_CTYPE=Chinese (Simplified)_China.936
# [3] LC_MONETARY=Chinese (Simplified)_China.936
# [4] LC_NUMERIC=C
# [5] LC_TIME=Chinese (Simplified)_China.936
#
# attached base packages:
# [1] stats graphics grDevices utils datasets methods
# [7] base
#
# other attached packages:
# [1] rgl_0.100.54 barplot3d_1.0.1
#
# loaded via a namespace (and not attached):
# [1] Rcpp_1.0.4.6 packrat_0.5.0
# [3] digest_0.6.25 later_1.1.0.1
# [5] mime_0.9 R6_2.4.1
# [7] xtable_1.8-4 jsonlite_1.7.0
# [9] magrittr_1.5 rlang_0.4.6
# [11] miniUI_0.1.1.1 promises_1.1.1
# [13] webshot_0.5.2 tools_3.6.3
# [15] manipulateWidget_0.10.1 htmlwidgets_1.5.1
# [17] crosstalk_1.1.0.1 shiny_1.5.0
# [19] fastmap_1.0.1 httpuv_1.5.4
# [21] xfun_0.15 compiler_3.6.3
# [23] htmltools_0.5.0 knitr_1.29
使用R包barplot3d绘制3D条形图-2020-07-04Sat相关推荐
- R语言可视化包ggplot2绘制排序条形图实战:按照分类因子排序、按照数值排序
R语言可视化包ggplot2绘制排序条形图实战:按照分类因子排序.按照数值排序 目录
- R包ComplexHeatmap绘制个性化热图
使用ComplexHeatmap包绘制个性化热图 作者:刘梦瑶 诺禾致源 微生物信息 审稿:刘永鑫 中国科学院遗传与发育生物学研究所 ComplexHeatmap包由顾祖光博士创建,是一个非常全面的绘 ...
- R包ggseqlogo |绘制序列分析图
简介 在生物信息分析中,经常会做序列分析图(sequence logo),这里的序列指的是核苷酸(DNA/RNA链中)或氨基酸(在蛋白质序列中).sequence logo图是用来可视化一段序列某个位 ...
- 使用R包networkD3绘制炫酷的动态关系网络
引言 在数据可视化领域,关系网络数据的可视化一直是一个受到广泛关注的话题. 我们经常会看到这样的复杂网络关系图. 也会经常看到一些影视作品的人物关系图,例如: 我们可以从图中清晰地了解到不同人物之间的 ...
- R包ggalluvial绘制冲击图(alluvial diagram)
ggalluvial是一个基于ggplot2的扩展包,冲击图(alluvial diagram)是流程图(flow diagram)的一种,最初开发用于代表网络结构的时间变化. R代码 ...
- python金字塔图绘制_如何用R或Python绘制3d(4变量)三元(金字塔)图?
嗯,我自己用了wikipedia article.SO post和一些蛮力解决了这个问题.对不起,代码墙,但你必须画出所有的绘图轮廓和标签等等.在import numpy as np import m ...
- 使用R包topGO绘制GO有向无环图
GO有向无环图 topGO 官方说明链接:http://www.bioconductor.org/packages/release/bioc/html/topGO.html 实战代码 ##R脚本 bi ...
- 一个震撼的交互型3D可视化R包 - 可直接转ggplot2图为3D
一个震撼的交互型3D可视化R包 - rayshader 虽然3D的plot见得比较多了,但是看见这样的R包,我的心还是砰了一下,这个简直不能再好看了! 关键是!!!敲黑板,这个R包超简单!!!对于刚学 ...
- R语言可视化包ggplot2绘制分组的条形图(bar plot、柱状图)实战:多变量柱状图
R语言可视化包ggplot2绘制分组的条形图(bar plot.柱状图)实战:多变量柱状图 目录
- R语言gg3D包绘制3D图形
本次分享一个绘图还不错的包--gg3D,2018年1月公布. 一.安装包 gg3D包目前(写该文章时)在R语言官方网站还不能找到并下载,但可以通过开源的托管平台gitHub下载. 运行如下代码: in ...
最新文章
- 黑马lavarel教程---7、文件上传
- python 新建文件 hdfs_大数据学习(六):Python操作hdfs(包括追加数据文件到hdfs文件)...
- 泛型擦除机制、自定义注解、代理、反射
- 大话数据结构 06:栈 顺序存储结构
- 计算机基础:信息安全相关知识笔记
- 程序员生活之路--来自程序员爸爸的一封信
- 【渝粤题库】广东开放大学 英语语法与基础写作 形成性考核 (2)
- TCP/IP系列——长连接与短连接的区别
- android apk 防止反编译技术加壳技术(转)
- DLUTOJ 1033 Matrix
- Java Lambda 表达式
- JProfiler12 最新使用教程
- 复联4里的钢铁侠原型是谁?(剧透警告慎入)
- 【MacOS】MacOS 添加虚拟打印机
- 40岁后学习编程是否太晚了?7点技巧让学习变得轻松有趣
- 显卡上DirectX 9.0 是什么意思
- Devtools下载添加到谷歌扩展程序
- DirectShow2
- 英文查错系统【浙江工商大学oj 测试点分析】
- 代码审计-md5加密相等绕过