{"id":23906,"date":"2024-01-09T17:34:30","date_gmt":"2024-01-09T09:34:30","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=23906"},"modified":"2024-01-09T17:34:31","modified_gmt":"2024-01-09T09:34:31","slug":"ggpubr%e5%85%a8%e8%83%bd%e4%bd%9c%e5%9b%be%e5%8c%85","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=23906","title":{"rendered":"ggpubr\u5168\u80fd\u4f5c\u56fe\u5305"},"content":{"rendered":"<p>\u5728\u524d\u6587\u4e2d\u6211\u4eec\u4ecb\u7ecd\u4e86\u4e00\u4e9b\u6709\u5173\u4e0eggpubr\u7684\u4e00\u4e9b\u7ed8\u56fe\u7684\u529f\u80fd\uff0c\u4f46\u662f\u8fd9\u4e2a\u5168\u529f\u80fd\u7684\u5305\u8fd8\u53ef\u4ee5\u7ed8\u5236\u975e\u5e38\u591a\u7684\u56fe\u5f62\uff0c\u4eca\u5929\u6211\u4eec\u6765\u76d8\u70b9ggpubr\u7684\u56fe\u5f62\u5927\u5168\u3002<\/p>\n<p>\u5904\u7406\u6570\u636e\u7684\u65f6\u5019\u4e3b\u8981\u63a5\u89e6\u7684\u662f\u6570\u636e\u7c7b\u578b\u4e3a\uff0c\u5355\u53d8\u91cf\u56e0\u7d20\u8fde\u7eed\u578b\u6570\u636e\uff1b\u53cc\u53d8\u91cfX\u79bb\u6563\uff0cY\u8fde\u7eed\uff1b\u53cc\u53d8\u91cfX\uff0cY\u90fd\u8fde\u7eed\u8fd9\u51e0\u4e2a\u4e86\u7c7b\u578b\u3002<\/p>\n<h2>\u5bc6\u5ea6\u5206\u5e03\u56fe\u3001\u76f4\u65b9\u56fe<\/h2>\n<p>\u5bf9\u4e8e\u5355\u53d8\u91cf\u56e0\u7d20\u8fde\u7eed\u578b\u6570\u636e\u4e00\u822c\u7528\u5bc6\u5ea6\u5206\u5e03\u56fe\u3001\u76f4\u65b9\u56fe\u6765\u8868\u793a\uff0c\u90a3ggpuber\u4e5f\u63d0\u4f9b\u4e86\u76f8\u5173\u7684\u7ed8\u56fe\u529f\u80fd\u3002<\/p>\n<h3>\u5bc6\u5ea6\u5206\u5e03\u56fe<\/h3>\n<p>#\u52a0\u8f7d\u76f8\u5e94\u7684R\u5305<\/p>\n<p>library(ggplot2)<\/p>\n<p>library(ggpubr)<\/p>\n<p>#\u6784\u5efa\u6570\u636e\u96c6,\u968f\u673a\u6784\u5efa\u4e00\u4e2a\u4e2a\u6570\u636e\u6846\uff0c\u5305\u62ecABCD\u56db\u4e2a\u7ec4\u522b<\/p>\n<p>set.seed(1234)<\/p>\n<p>mydata &lt;- data.frame(<\/p>\n<p>group = rep(c(&#8220;A&#8221;, &#8220;B&#8221;,&#8221;C&#8221;,&#8221;D&#8221;), each=200),<\/p>\n<p>value = c(rnorm(200, mean = 2), rnorm(200, 6),rnorm(200,2,4),rnorm(200,6,4))<\/p>\n<p>)<\/p>\n<p>#\u7528ggdensity\u7ed8\u5236\u5bc6\u5ea6\u56fe<\/p>\n<p>ggdensity(mydata, x = &#8220;value&#8221;, y=&#8221;..density..&#8221;, #\u4e5f\u53ef\u9009\u62e9&#8221;..count..&#8221;<\/p>\n<p>fill = &#8220;lightblue&#8221;,<\/p>\n<p>add = &#8220;mean&#8221;, #\u6216\u8005&#8221;median&#8221;,<\/p>\n<p>rug = TRUE #\u5728\u56fe\u5f62\u4e0b\u65b9\u6dfb\u52a0\u7684\u5bc6\u5ea6\u6807\u5ea6<\/p>\n<p>)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"576\" class=\"wp-image-23907\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-19-07-39-18.png?resize=640%2C576\" alt=\"\u622a\u5c4f2023-06-19 07.39.18\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-19-07-39-18.png?w=916 916w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-19-07-39-18.png?resize=300%2C270 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-19-07-39-18.png?resize=768%2C691 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-19-07-39-18.png?resize=600%2C540 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<h3>\u5206\u7ec4\u7ed8\u5236\u5bc6\u5ea6\u56fe<\/h3>\n<p>#\u5206\u7ec4\u7ed8\u5236\u5bc6\u5ea6\u76f4\u65b9\u56fe<\/p>\n<p>ggdensity(mydata, x = &#8220;value&#8221;,<\/p>\n<p>facet.by=&#8221;group&#8221;, #\u6309\u7167\u5206\u7ec4\u8fdb\u884c\u5206\u9762\u5904\u7406<\/p>\n<p>color = &#8220;group&#8221;, fill=&#8221;group&#8221;, #\u586b\u5145\u6309\u7167\u7ec4\u522b\u6620\u5c04<\/p>\n<p>palette = &#8220;lancet&#8221;,#\u53ef\u4ee5\u9009\u62e9&#8221;npg&#8221;, &#8220;aaas&#8221;, &#8220;lancet&#8221;, &#8220;jco&#8221;, &#8220;ucscgb&#8221;, &#8220;uchicago&#8221;, &#8220;simpsons&#8221; and &#8220;rickandmorty&#8221;<\/p>\n<p>add = &#8220;mean&#8221;,<\/p>\n<p>rug = TRUE,<\/p>\n<p>alpha=0.4, #\u8c03\u6574\u900f\u660e\u5ea6<\/p>\n<p>xlab=F,ylab = &#8220;Density&#8221;,<\/p>\n<p>panel.labs=list(group = c(&#8220;A&#8221;, &#8220;B&#8221;, &#8220;C&#8221;, &#8220;D&#8221;)), #\u4fee\u6539\u6bcf\u4e2apanel\u7684\u540d\u5b57<\/p>\n<p>ggtheme=theme_bw() #\u53ef\u4ee5\u662fggplot2\u4e2d\u7684\u4e3b\u9898\u7c7b\u578b<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"487\" class=\"wp-image-23908\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-10-39.png?resize=640%2C487\" alt=\"\u622a\u5c4f2023-06-13 14.10.39\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-10-39.png?w=1074 1074w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-10-39.png?resize=300%2C228 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-10-39.png?resize=1024%2C780 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-10-39.png?resize=768%2C585 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-10-39.png?resize=600%2C457 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>#\u8fd8\u53ef\u4ee5\u6dfb\u52a0\u76f8\u5e94\u7684\u6b63\u6001\u66f2\u7ebf\u6765\u5c55\u793a<\/p>\n<p>p+stat_overlay_normal_density(color = &#8220;black&#8221;, linetype = &#8220;dashed&#8221;)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"495\" class=\"wp-image-23909\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-15-56.png?resize=640%2C495\" alt=\"\u622a\u5c4f2023-06-13 14.15.56\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-15-56.png?w=1023 1023w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-15-56.png?resize=300%2C232 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-15-56.png?resize=768%2C595 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-15-56.png?resize=600%2C465 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<h3>\u76f4\u65b9\u56fe<\/h3>\n<p>#\u76f4\u65b9\u56fe\u5c55\u793a<\/p>\n<p>gghistogram(mydata, x = &#8220;value&#8221;, fill = &#8220;group&#8221;,add = &#8220;mean&#8221;, rug = TRUE, palette = c(&#8220;#00AFBB&#8221;, &#8220;#E7B800&#8243;,&#8221;pink&#8221;,&#8221;lightgreen&#8221;))<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"496\" class=\"wp-image-23910\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-22-40.png?resize=640%2C496\" alt=\"\u622a\u5c4f2023-06-13 14.22.40\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-22-40.png?w=1052 1052w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-22-40.png?resize=300%2C233 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-22-40.png?resize=1024%2C794 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-22-40.png?resize=768%2C596 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-22-40.png?resize=600%2C465 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<h3>\u5206\u9762\u76f4\u65b9\u56fe<\/h3>\n<p>gghistogram(mydata, x = &#8220;value&#8221;,facet.by = &#8220;group&#8221;#\u5206\u9762\u64cd\u4f5c<\/p>\n<p>,add_density = TRUE,#\u6dfb\u52a0\u5bc6\u5ea6\u66f2\u7ebf<\/p>\n<p>fill = &#8220;group&#8221;,add = &#8220;mean&#8221;, rug = TRUE, palette = c(&#8220;#00AFBB&#8221;, &#8220;#E7B800&#8243;,&#8221;pink&#8221;,&#8221;lightgreen&#8221;))<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"491\" class=\"wp-image-23911\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-24-24.png?resize=640%2C491\" alt=\"\u622a\u5c4f2023-06-13 14.24.24\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-24-24.png?w=1068 1068w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-24-24.png?resize=300%2C230 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-24-24.png?resize=1024%2C786 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-24-24.png?resize=768%2C590 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-24-24.png?resize=600%2C461 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<h2>\u7bb1\u7ebf\u56fe\uff0c\u5c0f\u63d0\u7434\u56fe\uff0c\u6761\u5f62\u56fe\uff0c\u70b9\u72b6\u56fe<\/h2>\n<p>\u79bb\u6563\u578b\u7684\u6570\u636e\uff08X\u4e3a\u79bb\u6563\u7684\uff09\u2014\u2014\u7bb1\u7ebf\u56fe\uff0c\u5c0f\u63d0\u7434\u56fe\uff0c\u6761\u5f62\u56fe\uff0c\u70b9\u72b6\u56fe\u7b49\u3002<\/p>\n<p>\u5728\u4ee5\u524d\u7684\u6587\u7ae0\u4e2d\u6211\u4eec\u4e5f\u7ed9\u4e88\u4e86\u4e00\u5199\u5c0f\u63d0\u7434\u7684\u4f5c\u56fe\u65b9\u6cd5\uff0c\u4eca\u5929\u6253\u5305\u6c47\u603b\u5404\u79cd\u56fe\u7684\u505a\u6cd5\u3002<\/p>\n<p>\u7b80\u5355\u7684\u7bb1\u7ebf\u56fe\u7ed8\u5236\uff1a<\/p>\n<p>ggboxplot(mydata, x = &#8220;group&#8221;, y = &#8220;value&#8221;, width = 0.8)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"495\" class=\"wp-image-23912\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-55-11.png?resize=640%2C495\" alt=\"\u622a\u5c4f2023-06-13 14.55.11\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-55-11.png?w=731 731w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-55-11.png?resize=300%2C232 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-14-55-11.png?resize=600%2C464 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>ggboxplot(mydata, x = &#8220;group&#8221;, y = &#8220;value&#8221;, width = 0.8,<\/p>\n<p>select = c(&#8220;A&#8221;,&#8221;B&#8221;),#\u5982\u679c\u53ea\u60f3\u7ed8\u5236\u67d0\u4e2a\u7ec4\u4e2d\u7684\u53ef\u4ee5\u9009\u62e9<\/p>\n<p>orientation = &#8220;horizontal&#8221;,#\u7bb1\u7ebf\u56fe\u7684\u65b9\u5411<\/p>\n<p>fill = &#8220;group&#8221;,#\u586b\u5145\u6620\u5c04\u5230\u5206\u7ec4\u4e0a<\/p>\n<p>palette = c(&#8220;#00AFBB&#8221;, &#8220;#E7B800&#8221;),<\/p>\n<p>add = &#8220;dotplot&#8221;,#\u6dfb\u52a0\u6563\u70b9\u5728\u56fe\u4e2d,\u8fd8\u53ef\u4ee5\u9009\u62e9&#8221;none&#8221;, &#8220;dotplot&#8221;, &#8220;jitter&#8221;, &#8220;boxplot&#8221;, &#8220;point&#8221;, &#8220;mean&#8221;, &#8220;mean_se&#8221;, &#8220;mean_sd&#8221;, &#8220;mean_ci&#8221;, &#8220;mean_range&#8221;, &#8220;median&#8221;, &#8220;median_iqr&#8221;, &#8220;median_hilow&#8221;, &#8220;median_q1q3&#8221;, &#8220;median_mad&#8221;, &#8220;median_range&#8221;<\/p>\n<p>add.params=list(color = &#8220;lightblue&#8221;,size=0.5)#\u5bf9\u6dfb\u52a0\u7684\u5bf9\u8c61\u8fdb\u884c\u6027\u72b6\uff0c\u989c\u8272\uff0c\u5927\u5c0f\u7b49\u5b9a\u4e49) <img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"510\" class=\"wp-image-23913\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-02-26.png?resize=640%2C510\" alt=\"\u622a\u5c4f2023-06-13 15.02.26\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-02-26.png?w=1018 1018w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-02-26.png?resize=300%2C239 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-02-26.png?resize=768%2C613 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-02-26.png?resize=600%2C479 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<h3>\u5c0f\u63d0\u7434<\/h3>\n<p>\u5c0f\u63d0\u7434\u56fe\u7684\u7ed8\u5236\uff0c\u53ef\u4ee5\u67e5\u9605\u5c0f\u679c\u4ee5\u524d\u5199\u7684\u201c\u591a\u6e20\u9053\u7ed8\u5236\u5c0f\u63d0\u7434\u56fe\uff0c\u5b9e\u73b0\u4f5c\u56fe\u81ea\u7531\u201d\u7684\u6587\u7ae0\u3002<\/p>\n<h3>\u6761\u5f62\u56fe<\/h3>\n<p>data(&#8220;mtcars&#8221;)<\/p>\n<p>df2 &lt;- mtcars<\/p>\n<p>df2$cyl &lt;- factor(df2$cyl)<\/p>\n<p>df2$name &lt;- rownames(df2)#\u6dfb\u52a0\u4e00\u884cname<\/p>\n<p>head(df2[, c(&#8220;name&#8221;, &#8220;wt&#8221;, &#8220;mpg&#8221;, &#8220;cyl&#8221;)])<\/p>\n<p>ggbarplot(df2, x=&#8221;name&#8221;, y=&#8221;mpg&#8221;, fill = &#8220;cyl&#8221;, color = &#8220;white&#8221;,<\/p>\n<p>palette = &#8220;jco&#8221;,#jco\u7684\u914d\u8272<\/p>\n<p>sort.val = &#8220;asc&#8221;,#\u4e0a\u5347\u6392\u5e8f<\/p>\n<p>sort.by.groups=TRUE,#\u6309\u7ec4\u6392\u5e8f<\/p>\n<p>x.text.angle=90)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"488\" class=\"wp-image-23914\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-28-46.png?resize=640%2C488\" alt=\"\u622a\u5c4f2023-06-13 15.28.46\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-28-46.png?w=1070 1070w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-28-46.png?resize=300%2C229 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-28-46.png?resize=1024%2C781 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-28-46.png?resize=768%2C586 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-28-46.png?resize=600%2C458 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<h3>\u504f\u5dee\u56fe<\/h3>\n<p>df2$mpg_z &lt;- (df2$mpg-mean(df2$mpg))\/sd(df2$mpg)<\/p>\n<p>df2$mpg_grp &lt;- factor(ifelse(df2$mpg_z&lt;0, &#8220;low&#8221;, &#8220;high&#8221;), levels = c(&#8220;low&#8221;, &#8220;high&#8221;))<\/p>\n<p>head(df2[, c(&#8220;name&#8221;, &#8220;wt&#8221;, &#8220;mpg&#8221;, &#8220;mpg_grp&#8221;, &#8220;cyl&#8221;)])<\/p>\n<p>ggbarplot(df2, x=&#8221;name&#8221;, y=&#8221;mpg_z&#8221;, fill = &#8220;mpg_grp&#8221;, color = &#8220;white&#8221;,<\/p>\n<p>palette = &#8220;jco&#8221;, sort.val = &#8220;asc&#8221;, sort.by.groups = FALSE, x.text.angle=60,<\/p>\n<p>ylab = &#8220;MPG z-score&#8221;, xlab = FALSE, legend.title=&#8221;MPG Group&#8221;)<\/p>\n<p>ggbarplot(df2, x=&#8221;name&#8221;, y=&#8221;mpg_z&#8221;, fill = &#8220;mpg_grp&#8221;, color = &#8220;white&#8221;,<\/p>\n<p>palette = &#8220;jco&#8221;, sort.val = &#8220;desc&#8221;, sort.by.groups = FALSE,<\/p>\n<p>x.text.angle=90, ylab = &#8220;MPG z-score&#8221;, xlab = FALSE,<\/p>\n<p>legend.title=&#8221;MPG Group&#8221;, rotate=TRUE,#\u662f\u5426\u65cb\u8f6c\u7684\u53c2\u6570<\/p>\n<p>ggtheme = theme_minimal())#\u4e00\u822c\u6211\u4eec\u7528\u7684\u504f\u5dee\u56fe\u90fd\u662f\u65cb\u8f6c90\u5ea6\u7684\u76f4\u65b9\u56fe<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"495\" class=\"wp-image-23915\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-43-39.png?resize=640%2C495\" alt=\"\u622a\u5c4f2023-06-13 15.43.39\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-43-39.png?w=1066 1066w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-43-39.png?resize=300%2C232 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-43-39.png?resize=1024%2C792 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-43-39.png?resize=768%2C594 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-43-39.png?resize=600%2C464 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<h3>\u70b9\u56fe<\/h3>\n<p>\u68d2\u68d2\u56fe\u53ef\u4ee5\u4ee3\u66ff\u67f1\u72b6\u56fe\u6765\u5c55\u793a\u76f8\u5e94\u7684\u7ed3\u679c\uff0cggpubr\u5305\u4e2d\u4e5f\u6709\u76f8\u5e94\u7684\u51fd\u6570\u3002<\/p>\n<p>\u8fd9\u91cc\u7b80\u5355\u7684\u5c55\u793a\u68d2\u68d2\u56fe\u7684\u505a\u6cd5\uff0c\u5bf9\u4e8e\u504f\u5dee\u56fe\u4e0e\u67f1\u72b6\u56fe\u7c7b\u4f3c\u3002<\/p>\n<p>ggdotchart(df2, x=&#8221;name&#8221;, y=&#8221;mpg&#8221;, color = &#8220;cyl&#8221;,<\/p>\n<p>palette = c(&#8220;#00AFBB&#8221;, &#8220;#E7B800&#8221;, &#8220;#FC4E07&#8221;), sorting = &#8220;ascending&#8221;,<\/p>\n<p>add = &#8220;segments&#8221;, ggtheme = theme_pubr())<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"488\" class=\"wp-image-23916\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-47-55.png?resize=640%2C488\" alt=\"\u622a\u5c4f2023-06-13 15.47.55\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-47-55.png?w=1068 1068w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-47-55.png?resize=300%2C229 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-47-55.png?resize=1024%2C780 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-47-55.png?resize=768%2C585 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/2023-06-13-15-47-55.png?resize=600%2C457 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<h3>\u76f8\u5173\u7ebf\u6027\u5206\u6790\u56fe<\/h3>\n<p>\u5bf9\u4e8e\u53cc\u53d8\u91cfX\uff0cY\u90fd\u8fde\u7eed\u8fd9\u4e2a\u6570\u636e\u7c7b\u578b\uff0c\u4e00\u822c\u91c7\u7528\u76f8\u5173\u7ebf\u6027\u5206\u6790\u6765\u89e3\u51b3\uff0c\u8fd9\u4e00\u90e8\u5206\u5c0f\u679c\u4e5f\u6709\u5199\u8fc7\u4e00\u7247\u6709\u5173\u4e8e\u76f8\u5173\u6027\u5206\u6790\u7684\u56fe\u7684\u7ed8\u5236\u3002<\/p>\n<p>data(&#8220;iris&#8221;)<\/p>\n<p>p &lt;- ggplot(data = iris, aes(x = Sepal.Width, y = Petal.Width, color = Species)) + geom_point() + geom_smooth(method = lm) +<\/p>\n<p>scale_color_manual(values = c(&#8216;#FF7400&#8217;, &#8216;#009999&#8217;, &#8216;#3914AF&#8217;)) +<\/p>\n<p>labs(title = &#8216;iris&#8217;) +<\/p>\n<p>theme_bw() + theme(plot.title = element_text(hjust = 0.5)) +<\/p>\n<p>stat_cor(method = &#8216;pearson&#8217;, aes(x = Sepal.Width, y = Petal.Width, color = Species))<\/p>\n<p>p<\/p>\n<p>\u4ece\u4ee5\u4e0a\u7684\u5c55\u793a\u4e2d\u53ef\u4ee5\u770b\u5230\uff0cggpubr\u7684\u5168\u80fd\u6027\u975e\u5e38\u7684\u5f3a\uff0c\u53ef\u4ee5\u6db5\u76d6\u5f88\u591a\u56fe\u5f62\uff0c\u5e76\u4e14\u5feb\u901f\u7684\u5236\u4f5c\u76f8\u5e94\u7684\u56fe\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u8fd9\u6837\u6211\u4eecggpubr\u5305\u7684\u5206\u4eab\u5c31\u5b8c\u6210\u4e86\u3002\u5c0f\u4f19\u4f34\u4eec\u5982\u679c\u6709\u4ec0\u4e48\u95ee\u9898\u5c31\u548c\u5c0f\u679c\u8ba8\u8bba\u5427\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u524d\u6587\u4e2d\u6211\u4eec\u4ecb\u7ecd\u4e86\u4e00\u4e9b\u6709\u5173\u4e0eggpubr\u7684\u4e00\u4e9b\u7ed8\u56fe\u7684\u529f\u80fd\uff0c\u4f46\u662f\u8fd9\u4e2a\u5168\u529f\u80fd\u7684\u5305\u8fd8\u53ef\u4ee5\u7ed8\u5236\u975e\u5e38\u591a\u7684\u56fe\u5f62\uff0c\u4eca\u5929\u6211\u4eec\u6765 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/23906"}],"collection":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=23906"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/23906\/revisions"}],"predecessor-version":[{"id":23917,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/23906\/revisions\/23917"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23906"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}