gpt4 book ai didi

r - 如何将radarchart ("fmsb"包中的默认标签字体类型更改为斜体)?

转载 作者:行者123 更新时间:2023-12-04 03:14:52 32 4
gpt4 key购买 nike

我创建了一个雷达图,用于显示许多物种的文化指数 (CI) 相对于位置的变化。但是,由于物种名称必须以斜体或下划线书写,因此我需要更改用于标签项的默认字体类型。我已经在互联网上搜索了很多天,但没有成功。看来question has been asked before但没有实质性的答案。我将不胜感激任何帮助。
这是我的 data这是代码:

library(fmsb)
colors_border=c( rgb(0.2,0.5,0.5,0.9), rgb(0.8,0.2,0.5,0.9) , rgb(0.7,0.5,0.1,0.9))
colors_in=c(rgb(0.2,0.5,0.5,0.3), rgb(0.8,0.2,0.5,0.3) , rgb(0.7,0.5,0.1,0.3))
radarchart( data , axistype=1 , pcol=colors_border, pfcol=colors_in, plwd=2.5, plty=1, cglcol="grey", cglty=1, axislabcol="grey40", caxislabels=seq(0,1,0.25), cglwd=0.8, calcex = 0.8, vlabels = c("A. pubescens", "A. alboviolaceum", "A. angustifolium", "A. melegueta", "C. anisata", "C. giganteus", "L. chevalieri", "M. myristica", "P. guineense", "S. longipedunculata", "T. sanguinea", "U. chamae", "X. aethiopica", "Z. zanthoxyloides"), vlcex=0.8)
legend(x=1.3, y=1.2, legend = rownames(data[-c(1,2),]), bty = "n", pch=20, col=colors_border, text.col = "grey25", cex=0.8, pt.cex=1.5)
radarchart()输出:

radarchart() output

最佳答案

我终于找到了解决方案。我们需要的只是在调用 radarchart() 之前将系列和字体绘图参数设置为我们想要的值。 .这可以通过 par() 完成.
设置默认字体系列

op <- par(family = "Times New Roman", font=3)
colors_border=c( rgb(0.2,0.5,0.5,0.9), rgb(0.8,0.2,0.5,0.9), rgb(0.7,0.5,0.1,0.9))
colors_in=c(rgb(0.2,0.5,0.5,0.3), rgb(0.8,0.2,0.5,0.3),
rgb(0.7,0.5,0.1,0.3))
绘制雷达图
radarchart( data  , axistype=1,pcol=colors_border, pfcol=colors_in,
plwd=2.5, plty=1, cglcol="grey", cglty=1, axislabcol="grey40",
caxislabels=seq(0,1,0.25), cglwd=0.8, calcex = 0.8, vlcex=0.8, vlabels = c("A. pubescens", "A. alboviolaceum", "A. angustifolium", "A. melegueta", "C. anisata", "C. giganteus", "L. chevalieri", "M. tenuifolia", "P. guineense", "S. lonipedunculata", "T. sanguinea", "U. chamae", "X. aethiopica", "Z. zanthoxyloides"))
重置绘图参数 par(op)上面的代码产生:
Image
来源: How to change font family in a legend in an R-plot?

关于r - 如何将radarchart ("fmsb"包中的默认标签字体类型更改为斜体)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42029645/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com