【问题标题】:degree symbol incorrect in ggplot map axis labels on Windows 10Windows 10 上的 ggplot 地图轴标签中的度数符号不正确
【发布时间】:2021-05-05 23:48:35
【问题描述】:

这个问题与r - degree symbol incorrect in map axis labels 非常相似,尽管那是在 Linux 机器上。我在 Windows 10 上遇到了类似的问题。

library(sf)                                            
library(ggplot2) 
                                      
nc = st_read(system.file("shape/nc.shp", package="sf"))

ggplot() +                                             
  geom_sf(data = nc)

产生以下内容:

我希望度数符号能够正确渲染,并怀疑这与 Windoze 字体有关。但是,我不确定如何最好地解决这个问题。

另一个问题的answer 涉及编辑/etc/fonts/local.conf 文件。我在系统上找到了几个这样的文件,其中一个在 R 目录中,但是对于旧版本的 R。我有点厌倦了在不了解我在做什么的情况下编辑随机配置文件。任何见解将不胜感激。

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    我的解决方案是 xlab 和 ylabs 中的 ad seq

    perurna = rnaturalearth::ne_countries(country = 'PERU',returnclass = 'sf')
    perurna
    
    xlabs = seq(-81,-68, 2)
    ylabs = seq(-18, -0,3)
    perurna
    
      ggplot(data =et1)+
      geom_point(aes(x = Longitud, y = Latitud,color=value),size=2) +
      geom_sf(fill='transparent',data=perurna, colour = "transparent")+
      scale_x_continuous(breaks = xlabs, labels = paste0(xlabs,'°W')) +
      scale_y_continuous(breaks = ylabs, labels = paste0(ylabs,'°S')) +
      geom_polygon(data=shp2, aes(x=long, y=lat, group=group),color = "black",fill=NA, size = .1)+
      scale_color_gradientn(colours = rainbow(5),breaks=seq(-1,1,0.2),limits=c(-1,1))+
      geom_point(aes(x = Longitud, y = Latitud),colour = "black",alpha = 0.3,shape=21,size=2) +
      labs(x = "LON",y= "LAT",color = "PP CORR")+
      theme_cowplot()+
      ggtitle("Correlacion Precipitacion") + 
      theme(panel.grid.major = element_line(color='black',linetype = 'dashed',size = 0.1),
            panel.grid.minor = element_blank(),
            panel.ontop = TRUE,
            panel.background = element_rect(fill = NA,color='black'),
            plot.title = element_text(hjust = 0.5))+
      facet_wrap(~ variable)
    

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2019-12-19
    • 1970-01-01
    • 2020-08-19
    • 1970-01-01
    • 1970-01-01
    • 2020-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多