vs如何打开行数,vs如何调出行数

不少人都想知道vs如何打开行数的题,关于vs如何调出行数这类题,也一直是热点,小编为你详细的讲解一下吧!

vs如何打开行数

Linux体系检察体系进-程

运用下令ps,该下令参数较多这里不细讲,只推荐用到的,经常使用的a,u,x ,e,f,等,a是全部的,e也是一切的,相似于a,u用户,x是1种显现款式列出的内容更一五一十啦。

ps -aux | grep vsftpd

能够查到ftp办事进-程,第二条是这一个查进-程能够过滤掉,过滤办法是仍然运用grep -v ,-v的意义是不婚配或许除外的意义,详细成效以下

能够使用wc统计查的条数,运用wc -l,-l 意义便是统计行数,对于wc下令的运用能够依照下令手册,或许我的其余短文解说,这里只说用到的参数,以下

返回值1为一条,再联合软件编程中的popen等函数能够检测相干进-程情形作响应处置了。

有疑能够谈论留言或发私信我拉。

vs如何调出行数

简介

cowplot 包是 ggplot 的一位简易插件,能够对多个图形举行系列和对齐,来变成繁杂的出书级别的图片,还供应了一些主题和帮-助函数啦。

安置

install.packages(&34;)34;wilkelab/cowplot&39;red&39;blue&34;v&34;v&34;h&34;v&34;black&34;black&34;gray80&34;h&34;h&34;b&34;h&34;bt&34;other&39;v&34;l&39;v&39;l&34;34;) + scale_y_continuous( expand = expansion(mult = c(0, 0.05)), position = &34; ) + theme_minimal_hgrid(11, rel_small = 1) + theme( panel.grid.major = element_line(color = &6297E770&34;pt&34;34;), axis.title.y = element_text(color = &6297E7&34;34;) + scale_y_continuous(limits = c(10, 21)) + theme_half_open(11, rel_small = 1) + theme( axis.ticks.y = element_line(color = &BB2D05&34;34;), axis.title.y = element_text(color = &BB2D05&34;34;) )p2

aligned_plots <- align_plots(p1, p2, align=&34;, axis=&34;)ggdraw(aligned_plots[[1]]) + draw_plot(aligned_plots[[2]])3. 图上绘制图形

cowplot 包供给了用于在图上绘制的函数,这一些函数能够增添随意的图形.解释或者布景,能够在其余图上安置图形,或许组合区别的图形系统,如 ggplot2.grid.lattice.base,并回返一位 ggplot2 对-象呀。

3.1 增添解释

比方,关于底下这张图

p <- ggplot(mpg, aes(displ, cty)) + geom_point() + theme_minimal_grid(12)p

咋们运用 ggdraw() 将图封装成一位画图环-境,随后运用 draw*() 函数增加解释,比方,增添一位水印

ggdraw(p) + draw_label(&34;, color = &C0A0A0&34;Watermark&34;34;, inherit.aes = FALSE )

因为 ggplot2 的字体大小是 mm,须要除以 .pt 举行转换,而 draw_label 会在里面举行转换了。

咋们能够将 ggdraw() 当作 ggplot2 一位画图对-象,能够在后面修正主题

ggdraw(p) + draw_label(&34;, color = &C0A0A0&34;cornsilk&34;Watermark&34;34;, size = 50, angle = 45) + draw_plot(p)

上边的按例须要确保图片的布景是一切剔透的,比方,咋们将散点图的布景配置为 theme_classic() 水印将会被遮掩

ggdraw() + draw_label(&34;, color = &C0A0A0&34;Watermark&34;34;, size = 50, angle = 45) + draw_plot( p + theme_half_open() )3.2 插进图形

draw_plot() 函数应咋们将随意长短的图形安置在画布的随意地位,能够很简单地将一位图形嵌入到另一位图形中,构建组合图形

比方,在一位大图中,增加一位小图

inset <- ggplot(mpg, aes(drv)) + geom_bar(fill = &fb8072&34;A&34;B& 须要 gridGraphics 包34;gridGraphics& 配置为表达式的情势inset <- ~ggdraw(p + theme_half_open(12)) + draw_plot(inset, .45, .45, .5, .5) + draw_plot_label( c(&34;, &34;), c(0, 0.45), c(1, 0.95), size = 12 )3.3 相对地位

默许情形下,ggdraw() 函数运用的是对应地位,x 和 y 轴都是在 0-1 之中呢。

假如要经过相对地位举行定位,能够运用 grid 图形系统,并搭配 draw_grob() 绘制函数

比方,咋们在左上角 1 英寸处增加一位 1 英寸的正方形

library(grid)rect <- rectGrob( x = unit(1, &34;), y = unit(1, &34;) - unit(1, &34;), width = unit(1, &34;), height = unit(1, &34;), hjust = 0, vjust = 1, gp = gpar(fill = &34;, alpha = 0.5))ggdraw(p) + draw_grob(rect)

咋们更改图形的长短,可是正方形的长短和地位不会变

3.4 组合静態图片

draw_image() 能够在画图中增加静態图片,须要先安置 magick 包啦。

比方,增加背景图片

library(magick)library(magick)img <- system.file(&34;, &34;, package = &34;) %>% image_read() %>% image_resize(&34;) %>% image_colorize(35, &34;)p <- ggplot(mpg, aes(displ, fill = class)) + geom_density(alpha = 0.7) + scale_fill_grey() + coord_cartesian(expand = FALSE) + theme_minimal_hgrid(11, color = &34;)ggdraw() + draw_image(img) + draw_plot(p)

或许,增加 logo

logo_file <- system.file(&34;, &34;, package = &34;)ggdraw() + draw_plot(p) + draw_image( logo_file, x = 1, y = 1, hjust = 1, vjust = 1, halign = 1, valign = 1, width = 0.15 )4. 混淆区别画图框架

cowplot 画图函数(ggdraw().draw_plot().plot_grid())不单支撑 ggplot2 画图体系,还支撑 base 画图体系,可是要先安置 gridGraphics 包

比方,咋们用 ggdraw() 绘制根基图形,随后运用 ggplot2 主题

p1 <- function() ggdraw(p1) + theme(plot.background = element_rect(fill = &34;))

增添 logo

logo_file <- system.file(&34;, &34;, package = &34;)ggdraw() + draw_image( logo_file, x = 1, width = 0.1, hjust = 1, halign = 1, valign = 0 ) + draw_plot(p1)

运用 plot_grid() 函数能够将 base 和 ggplot2 图形与网格的布置绘制在一同

p2 <- ggplot(data = mtcars, aes(factor(cyl), mpg)) + geom_boxplot()plot_grid(p1, p2)

base 画图能够封装为函数的情势,并将响应的图形回返,作-为1种被纪录的画图呀。或许封装为表达式的情势,如 3.2 按例呢。

比方,咋们绘制一位根基图形

par(mar = c(3, 3, 1, 1), mgp = c(2, 1, 0))boxplot(mpg ~ cyl, xlab = &34;, ylab = &34;, data = mtcars)

这一个图形会被 recordPlot() 函数纪录,随后,能够运用 ggdraw() 函数对被纪录的图形举行绘制

p1_recorded <- recordPlot()ggdraw(p1_recorded)

咋们也能够将画图代码放在大括号中,并包裹成表达式

p1_formula <- ~ggdraw(p1_formula)

还支撑 lattice 图形和 grid 图形对-象

ggplot2p2 <- ggplot(data = mtcars, aes(factor(cyl), mpg)) + geom_boxplot() 圆形对-象library(grid)p4 <- circleGrob(r = 0.3, gp = gpar(fill = &34;))34;auto&34;First&34;Second&34;light blue&34;pink& 画图韦恩图并增添矩形框和边距ggdraw(p_venn) + theme( plot.background = element_rect(fill = NA), plot.margin = margin(12, 12, 12, 12) )5. 网格布置5.1 根本运用

plot_grid 用于将图形根据网格布置举行系列,他是基于 ggdraw() 和 draw_*() 函数来绘制图形,图形对齐是经过 align_plots() 函数呢。

plot_grid 能够很简单地对多个图形举行系列并增添标签

p1 <- ggplot(mtcars, aes(disp, mpg)) + geom_point(colour = &34;)p2 <- ggplot(mtcars, aes(qsec, mpg)) + geom_point(colour = &34;)plot_grid(p1, p2, labels = c(&39;, &39;))

假如将 labels 参数设置为 AUTO 或许 auto,会主动增添大写或者小写的标签

plot_grid(p1, p2, labels = &34;)

plot_grid(p1, p2, labels = &34;)

plot_grid 默许不会将图形对齐

p3 <- p1 + 有无对齐plot_grid(p3, p2, labels = &34;)

水准对齐

plot_grid(p3, p2, labels = &34;, align = &34;)5.2 图形微调

label_size 用于掌控标签的长短,默许为 14

plot_grid(p1, p2, labels = &34;, label_size = 12)

对字体举行调理

plot_grid( p1, p2, labels = &34;, label_fontfamily = &34;, label_fontface = &34;, label_colour = &34;)

能够运用 label_x 和 label_y 参数掌控标签的地位,hjust 和 vjust 参数用于掌控对齐方法

plot_grid( p1, p2, labels = &34;, label_size = 12, label_x = 0, label_y = 0, hjust = -0.5, vjust = -0.5)

固然,关于多个图形,能够通报向量值的方法来分-别掌控每一个图形

行数和列数能够运用 nrow 和 ncol 参数来掌控

plot_grid( p1, p2, labels = &34;, ncol = 1)

能够运用 NULL 来表现网格中该地位为空缺,假如配置了主动配置标签,也会为空缺图增添上标签

plot_grid( p1, NULL, NULL, p2, labels = &34;, ncol = 2)

rel_widths 和 rel_heights 参数用于配置图形的对应宽度和高度

plot_grid(p1, p2, labels = &34;, rel_widths = c(1, 2))5.3 嵌套画图

plot_grid() 能够嵌套运用,变成越发繁杂的图形布置,比方

bottom_row <- plot_grid(p1, p2, labels = c(&39;, &39;), label_size = 12)p3 <- ggplot(mtcars, aes(x = qsec, y = disp, colour = factor(gear))) + geom_point(show.legend = FALSE) + facet_wrap(~gear)plot_grid(p3, bottom_row, labels = c(&39;, &39;), label_size = 12, ncol = 1)

这类情形下,图形的对齐将会变的对比难题,咋们能够运用 align_plots() 函数来显式的对齐图形

39;v&39;l& 底行bottom_row <- plot_grid(plots[[2]], p2, labels = c(&39;, &39;), label_size = 12)39;A&39;&34;blue&39;none&34;green&39;none& 增添题目title <- ggdraw() + draw_label( &34;, fontface = &39;, x = 0, hjust = 0 ) + theme( 掌控题目与图形的高度含量 rel_heights = c(0.1, 1))6. 同享图例

底下,咋们推荐怎么样为组合图形配置图例,假定咋们有以下三个图形

dsamp <- diamonds[sample(nrow(diamonds), 1000), ] 增添图形p1 <- plot_diamonds(carat)p2 <- plot_diamonds(depth) + ylab(NULL)p3 <- plot_diamonds(color) + ylab(NULL)34;none&34;none&34;none&39;vh&34;A&34;B&34;C& 为图例留出充足空-间 p1 + theme(legend.box.margin = margin(0, 0, 0, 12))) 获得水准布置的图例legend_b <- get_legend( p1 + guides(color = guide_legend(nrow = 1)) + theme(legend.position = &34;)) 将全部图形安置在统一行,并在 B 和 C 之中留出空-间prow <- plot_grid( p1 + theme(legend.position=&34;), p2 + theme(legend.position=&34;), NULL, p3 + theme(legend.position=&34;), align = &39;, labels = c(&34;, &34;, &34;, &34;), hjust = -1, nrow = 1, rel_widths = c(1, 1, .3, 1)) plot 1p1 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + stat_smooth(method = &34;) + facet_grid(. ~ Species) + theme_half_open(12) + background_grid(major = &39;, minor = &34;) + panel_border() + theme(legend.position = &34;)34;top&34;none& plot 3p3 <- ggplot(iris, aes(Sepal.Width, fill = Species)) + geom_density(alpha = .7) + scale_y_continuous(expand = c(0, 0)) + theme_half_open(12) + theme(legend.position = &34;) 全部图形竖直对齐plots <- align_plots(p1, p2a, p3, align = &39;, axis = &39;)34;B&34;C& 组合一切图形plot_grid(plots[[1]], bottom_row, labels = c(&34;), ncol = 1)

对于一些vs如何打开行数和vs如何调出行数的题,本文讲解完,希望大家喜欢!


除非特别注明,本站所有文字均为原创文章,作者:admin

No Comment

留言

电子邮件地址不会被公开。 必填项已用*标注

感谢你的留言。。。