【问题标题】:Locate value "0" in the center of the Palette in a world map在世界地图的调色板中心找到值“0”
【发布时间】:2021-05-24 22:30:34
【问题描述】:

我目前正在分析某些指数对世界国家 (134) 的影响。此效果的范围为 (-1.01, 0.528)。鉴于“效果 = 0”位于调色板的右侧,它与绿色和黄色之间的变化不重合,因此该地图具有误导性。

  • 如何在调色板的刻度中“居中”值 0?为 0 区域上的这些值分配某种颜色会很神奇(除了大小,在我的分析中,正或负是至关重要的)。

  • 有没有办法为负值制作“红色”调色板,为正值制作“绿色”调色板?

  • 如何删除标题“index_effect”?

有什么线索吗?

谢谢

注意:我使用此代码的视频在此处https://www.youtube.com/watch?v=8dNBWESwcHU

我得到的代码和图如下:

# set the colour
colourPalette <- RColorBrewer::brewer.pal(10,'Spectral') 
# plot the info in the world map ("world_data" is my dataset)
mapCountryData(world_data,
               nameColumnToPlot = 'index_effect',
               catMethod = 'fixedwidth',
               mapRegion = 'world',
               colourPalette = 'diverging',
               numCats = 10)

【问题讨论】:

    标签: r ggplot2 plot palette rworldmap


    【解决方案1】:
    • 一种解决方案是将变量 index_effect 标准化(使其范围从 -1 到 1)。这样 0 将在 Palette 的中间。但是,这种重新缩放会转换感兴趣的值(这是要避免的),并且仍然无法使负值使用一个“红色”调色板,正值使用一个“绿色”调色板。
    • 另一种解决方案是制作 2 个不同的图:一个用于负值国家,另一个用于正值国家。

    【讨论】:

      猜你喜欢
      • 2015-05-29
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-14
      • 2011-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多