问题
数据有些多,原图不好复现,但是原因有:
plot_grid(xy_z_plot, xy_z_plot, labels = c("A", "B"), align = "v",nrow = 2)
> warnings()
警告信息:
...
12: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
'mbcsToSbcs'里转换'姘翠綅/m'出错:<8d>代替了dot
13: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
'mbcsToSbcs'里转换'涓嬫父闃叉椽鏍囧噯搴撴按浣嶅彉鍖栧浘'出错:<e4>代替了dot
14: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
我查了下,发现有同学在rmd中使用ggplot2时出现了这个问题,通过谢大的一个方法解决了,但是我尝试不成功……
另外
- warnings出现后再画任何图的时候RStudio右下图框再也显示不出来图了,只能restart and reload workspace……
- 有的说可能是字体的问题,我也把代码贴这里吧!一切问题都是在运行最上面那个代码的时候出现的。
- 我移除了所有汉字,warnings()没有出现了,但是图依旧没有,1中的情况仍然没变……
xy_io_plot <- ipl_xy %>% gather(inout,q,c(2,4))%>%
ggplot(aes(x = n,y = q,color = as.factor(inout),lty = as.factor(inout)))+
theme_bw()+
ggalt::geom_xspline(size = 1.5) +
theme(plot.subtitle = element_text(vjust = 1),
plot.caption = element_text(vjust = 1),
plot.title = element_text(hjust = 0.5),legend.title = element_blank(),
legend.justification = c(1,1),legend.position = c(0.99,0.99)) +
labs(title = "下游防洪标准水库调洪示意图",
x = "时间/h", y = expression(流量/(m^3/s)))+
scale_linetype_manual(values = c(1,5),
breaks = c("q_in","q_out"),
labels = c("入库流量","下泄流量"))+
scale_color_manual(values = c("red2","cyan"),
breaks = c("q_in","q_out"),
labels = c("入库流量","下泄流量"))
xy_z_plot <- ggplot(ipl_xy,aes(x = n,y = z))+
theme_bw()+
ggalt::geom_xspline(size = 1.2,color = "lightpink") +
theme(plot.subtitle = element_text(vjust = 1),
plot.caption = element_text(vjust = 1),
plot.title = element_text(hjust = 0.5)) +
labs(title = "下游防洪标准库水位变化图", x = "时间/t",
y = "水位/m")
plot_grid(xy_z_plot, xy_z_plot, labels = c("A", "B"), align = "v",nrow = 2)
系统信息
> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.3.0 cowplot_0.9.4 ourbir_0.1.0 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.0.1
[7] purrr_0.3.2 readr_1.3.1 tidyr_0.8.3 tibble_2.1.1 ggplot2_3.1.1 tidyverse_1.2.1
[13] data.table_1.12.0 multicolor_0.1.2 lubridate_1.7.4 praise_1.0.0 pacman_0.5.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 lattice_0.20-38 assertthat_0.2.1 digest_0.6.18 proj4_1.0-8
[6] mime_0.6 R6_2.4.0 cellranger_1.1.0 plyr_1.8.4 backports_1.1.3
[11] httr_1.4.0 pillar_1.3.1 Rmisc_1.5 rlang_0.3.4 lazyeval_0.2.2
[16] readxl_1.3.1 rstudioapi_0.10 miniUI_0.1.1.1 extrafontdb_1.0 labeling_0.3
[21] extrafont_0.17 ggalt_0.4.0 munsell_0.5.0 broom_0.5.1 httpuv_1.5.1
[26] compiler_3.5.2 modelr_0.1.3 pkgconfig_2.0.2 htmltools_0.3.6 tidyselect_0.2.5
[31] later_0.8.0 crayon_1.3.4 withr_2.1.2 MASS_7.3-51.1 grid_3.5.2
[36] xtable_1.8-3 nlme_3.1-137 jsonlite_1.6 Rttf2pt1_1.3.7 gtable_0.3.0
[41] magrittr_1.5 formatR_1.6 scales_1.0.0 ggThemeAssist_0.1.5 KernSmooth_2.23-15
[46] cli_1.1.0 stringi_1.4.3 promises_1.0.1 xml2_1.2.0 generics_0.0.2
[51] ash_1.0-15 RColorBrewer_1.1-2 Cairo_1.5-9 tools_3.5.2 glue_1.3.1
[56] maps_3.3.0 hms_0.4.2 yaml_2.2.0 colorspace_1.4-1 rvest_0.3.2
[61] haven_2.1.0