当前位置: 首页 > news >正文

哈尔滨网站建设设计公司厦门seo培训学校

哈尔滨网站建设设计公司,厦门seo培训学校,移动端网站开发教程,网站开发实验的总结实验7#xff1a;高级绘图#xff08;上#xff09; 一#xff1a;实验目的与要求 1#xff1a;了解R语言中各种图形元素的添加方法#xff0c;并能够灵活应用这些元素。 2#xff1a;了解R语言中的各种图形函数#xff0c;掌握常见图形的绘制方法。 二#xff1a;实…实验7高级绘图上 一实验目的与要求 1了解R语言中各种图形元素的添加方法并能够灵活应用这些元素。 2了解R语言中的各种图形函数掌握常见图形的绘制方法。 二实验内容 【lattice包绘图】 Eg.1以mtcars数据集为例绘制车身重量wt与每加仑汽油行驶的英里数mpg的散点图 library(lattice) xyplot(wt ~ mpg, data mtcars, xlab Weight, ylab Miles per Gallon, main lattice包绘制散点图) Eg.2查看参数列表名称 names(trellis.par.get()) Eg.3fontsize查看字体大小和散点大小的参数 op - trellis.par.get() trellis.par.get(fontsize) trellis.par.set(fontsize list(text 20, points 20)) xyplot(wt ~ mpg, data mtcars, xlab Weight, ylab Miles per Gallon, main lattice包绘制散点图) trellis.par.set(op) Eg.4图形化显示所有参数 show.settings() Eg.5以Species鸢尾花种类为条件变量绘制Sepal.Length花萼长度与Sepal.Width花萼宽度的散点图 library(lattice) attach(iris) xyplot(Sepal.Length ~ Sepal.Width | Species) detach(iris) Eg.6面板函数 my_panel - function(x,y){   panel.lmline(x, y, col red, lwd 1, lty 2)   panel.loess(x,y)   panel.grid(h -1, v -1)   panel.rug(x, y)   panel.xyplot(x, y) } xyplot(mpg ~ wt, data mtcars, xlab Weight, ylab Miles per Gallon,main Miles per Gallon on Weight, panel my_panel) Eg.7分组变量 xyplot(Sepal.Length ~ Sepal.Width, group Species, data iris,pch 1:3, col 1:3, main Sepal.Length VS Sepal.Width, key list(space right, title Species, cex.title 1, cex 1, text list(levels(factor(iris$Species))), pointslist(pch 1:3, col 1:3))) Eg.8图形组合 graph1 - xyplot(Sepal.Length ~ Sepal.Width | Species, data iris, main 栅栏图) graph2 - xyplot(Sepal.Length ~ Sepal.Width, group Species, data iris, main 散点图1) graph3 - xyplot(Petal.Length ~ Petal.Width, group Species, data iris, main 散点图2) # split函数 plot(graph1, split c(1,1,3,1)) plot(graph2, split c(2,1,3,1),newpageF) plot(graph2, split c(3,1,3,1),newpageF) # position函数 plot(graph1, position c(0, 0, 1/3, 1)) plot(graph2, position c(1/3, 0, 2/3, 1), newpage F) plot(graph3, position c(2/3, 0, 1, 1), newpage F) Eg.9条形图 barchart(VADeaths, main Death Rates in 1940 Virginia(By Group)) barchart(VADeaths, groups FALSE, main list(Death Rates in 1940 Virginia, cex 1.2)) Eg.10泰塔尼克号航行中不同人群获救与否的人数情况 str(Titanic) as.data.frame(Titanic) pic1 - barchart(Class ~ Freq|Age Sex, data as.data.frame(Titanic), groups Survived, stack TRUE, auto.key list(title Survived, columns 2)) pic2 - barchart(Class ~ Freq|Age Sex, data as.data.frame(Titanic), groups Survived, stack TRUE, auto.key list(title Survived, columns 2), scales list(x free)) pic3 - update(pic2, panelfunction(...){   panel.grid(h0,v-1)   panel.barchart(...,border Transparent) }) plot(pic1, split c(1,1,3,1)) plot(pic2, split c(2,1,3,1), newpage FALSE) plot(pic3, split c(3,1,3,1), newpage FALSE) Eg.11点图 dotplot(VADeaths, pch 1:4, xlab Death rates per 1000,         main list(Death Rates in 1940 Virginia (By Group), cex 0.8),         key list(column 4, text list(colnames(VADeaths)), points list(pch 1:4, col 1:4))) dotplot(VADeaths, group FALSE, xlab Death rates per 1000,main list(Death Rates in 1940 Virginia, cex 0.8)) Eg.12直方图 histogram( ~ height | voice.part, data singer, nint 17, layout c(1,8), xlab Height(inches)) Eg.13核密度图 densityplot( ~ height | voice.part, data singer, layoutc(1, 8), xlab Height (inches),main Heights of New York Choral Society singers) Eg.14叠加核密度图 densityplot( ~ height, group voice.part, data singer, xlab Height (inches) , plot.points FALSE,main Heights of New York Choral Society singers, lty 1:8, col 1:8, lwd 1.5,key list(text list(levels(singer$voice.part)), column 4, lines list(lty 1:8, col 1:8))) Eg.15添加核密度图 histogram( ~ height | voice.part, data singer,            xlab Height (inches), type density,            panel function(x, ...) {           panel.histogram(x, ...)           panel.mathdensity(dmath dnorm, col black,           args list(meanmean(x),sdsd(x))) }) Eg.16带状图 nrow(singer[singer$voice.part Bass 2, ]) stripplot(~ height, group voice.part, data singer, xlab Height (inches), main Heights of New York Choral Society singers,           subset (voice.part Bass 2),jitter.dataT) Eg.17QQ图 qqmath(~ height | voice.part, data singer, prepanel prepanel.qqmathline,        panel function(x, ...) {        panel.qqmathline(x, ...)        panel.qqmath(x, ...)        }) qq(voice.part ~ height, aspect 1, data singer,subset (voice.part Bass 2 | voice.part Tenor 2)) Eg.18箱线图 pic1 - bwplot( ~ height | voice.part, datasinger, xlabHeight (inches)) pic2 - bwplot(voice.part ~ height, datasinger, xlabHeight (inches)) plot(pic1, split c(1, 1, 2, 1)) plot(pic2, split c(2, 1, 2, 1), newpage FALSE) Eg.19散点图 xyplot(Sepal.Length~Sepal.Width|Species,datairis) Eg.20散点矩阵图 splom(iris[, 1:4], groups iris$Species, pscales 0, pch 1:3, col 1:3, varnames colnames(iris)[1:4],key list(columns 3, text list(levels(iris$Species)), points list(pch 1:3, col 1:3))) Eg.21三维水平图 data(Cars93, package MASS) cor.Cars93 -cor(Cars93[, !sapply(Cars93, is.factor)], use pair) levelplot(cor.Cars93, scales list(xlist(rot90))) Eg.22三维等高线 contourplot(volcano, cuts 20) Eg.23三维散点图 par.set -list(axis.line list(col transparent), clip list(panel off)) # 去除边框不削减面板范围 cloud(Sepal.Length ~ Petal.Length * Petal.Width, data iris, groups Species,         pch 1:3,col 1:3, # 点颜色及样式         screen list(z 20, x -70, y 0), # 调节三维散点图的展示角度         par.settings par.set,         scales list(col black), # 加箭头指示         keylist(column3, textlist(levels(iris$Species)), points list(pch 1:3, col 1:3))) Eg.24三维曲面图 par.set -list(axis.line list(col transparent), clip list(panel off)) # 去除边框不削减面板范围 wireframe(volcano, shade TRUE, par.settings par.set, aspect c(61/87, 0.4)) 【ggplot2包绘图】 Eg.1qplot函数 library(ggplot2) qplot(Species, Sepal.Length, data iris, geom boxplot, fill Species,main 依据种类分组的花萼长度箱线图) qplot(Species, Sepal.Length, data iris, geom c(violin, jitter), fill Species,main 依据种类分组的花萼长度小提琴图) qplot(Sepal.Length, Sepal.Width, data iris, colour Species, shape Species,main 绘制花萼长度和花萼宽度的散点图) qplot(Sepal.Length, Sepal.Width, data iris, geom c(point, smooth), facets ~Species,colour Species, main 绘制分面板的散点图) Eg.2语言逻辑 plot(iris$Sepal.Length, iris$Sepal.Width) library(ggplot2) ggplot(data iris, aes(x Sepal.Length, y Sepal.Width)) #绘制底层画布 geom_point(color darkred) #在画布上添加点 Eg.3绘制画布 ggplot(data iris, aes(x Sepal.Length, y Sepal.Width, colour Species, shape Species)) Eg.4几何对象 #  方法1 ggplot(data iris, aes(x Sepal.Length, y Sepal.Width, colour Species, shape Species))geom_point() # 方法2 ggplot(data iris) geom_point(aes(x Sepal.Length, y Sepal.Width, colour Species, shape Species)) Eg.5统计变换 # 方法1 ggplot(iris) geom_bar(aes(xSepal.Length), statbin, binwidth 0.5) # 方法2 ggplot(iris) stat_bin(aes(xSepal.Length), geombar, binwidth 0.5) Eg.6标尺设置 set.seed(1234) # 设置随机种子 my_iris - iris[sample(1:150, 100, replace FALSE),] # 随机抽样 p - ggplot(my_iris) geom_bar(aes(x Species, fill Species)) p # 左图 p$scales # 查看p的标尺参数 p scale_fill_manual(   values c(orange, olivedrab, navy), # 颜色设置   breaks c(setosa, versicolor, virginica), # 图例和轴要显示的分段点   name my_Species, # 图例和轴使用的名称   labels c(set, ver, vir) # 图例使用的标签   ) # 右图 Eg.7修改图形的颜色 ggplot(iris, aes(x Sepal.Length, y Sepal.Width, colour Species))   scale_color_manual(values c(orange, olivedrab, navy))   geom_point(size 2) ggplot(iris,aes(x Sepal.Length, y Sepal.Width, colour Species))   scale_color_brewer(palette Set1)   geom_point(size2) Eg.8坐标系转换 # 饼图 堆叠长条图 polar coordinates pie - ggplot(my_iris, aes(x factor(1), fill Species)) geom_bar(width 1) pie coord_polar(theta y) # 靶心图 饼图 polar coordinates pie coord_polar() #锯齿图 柱状图 polar coordinates cxc - ggplot(my_iris, aes(x Species)) geom_bar(width 1, colour black) cxc coord_polar() Eg.9分面 library(ggplot2) library(tidyr) library(dplyr) my_iris1 - iris %% gather(feature_name, feature_value, one_of(c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width))) # 数据变换 ggplot(my_iris1) geom_violin(aes(x Species, y feature_value)) facet_grid(feature_name ~ Species, scales free) # 分面 Eg.10facet-wrap函数 ggplot(my_iris1) geom_violin(aes(x Species, y feature_value)) facet_wrap(~ feature_name Species, scales free) Eg.11保存图形 ggplot(iris, aes(x Sepal.Length, y Sepal.Width, colour Species))geom_point(size 2) ggsave(file mygraph.pdf, width 5, height 4)
http://www.zqtcl.cn/news/412832/

相关文章:

  • 商务网站建设有哪几个步骤拼多多网页qq登录
  • 厦门商城网站开发宜昌小程序开发公司
  • 东莞沙田网站建设榆林网站建设价格
  • 无锡网站制作建设wordpress写文章模板
  • 企业网站销售提升学历要多少钱
  • 打开建设银行官方网站首页wordpress 站库分离
  • 电子商务网站建设的试卷设计之家app
  • 抚养网站建设黔东南小程序开发公司
  • 网站建设相关行业有哪些wordpress 内容管理系统
  • 网站 备案地温州网站优化排名推广
  • 做网站的工作量国内 wordpress
  • 定制网站开发是什么大业推广网站
  • 网站建设每年需要交多少钱天津制作网站公司
  • 网站平台都有哪些wordpress 主题制作 视频
  • 中山网站建设方案家具网站开发目的
  • 教师个人网站建设建模培训多少钱
  • 个人网站可以做社交类型网站建设功能说明书
  • 微站是什么移动网站 拉新
  • 黑龙江省农业网站建设情况wordpress4.94主题上传不显示
  • 个人网站的域名重庆建立公司网站
  • 什么做网站做个多少钱啊百度网盘app
  • 做网站的公司挣钱吗石家庄房产
  • 烟台网站建设设计公司安徽建设工程信息网查询平台蔡庆树
  • 微信链接的微网站怎么做西安企业网站制作价格
  • uniapp怎么做淘客网站表格布局的网站
  • wordpress侧栏图片插件提升seo搜索排名
  • 如何查询网站的域名注册邹城建设银行网站
  • 招生门户网站建设方案国家企业信用信息公示信息查询网
  • 用dw做淘客网站的步骤移动互联网应用技术
  • 企业合作的响应式网站石家庄网站建设推广