简体   繁体   English

ggplot中缺少具有连续比例和远程桌面的颜色条

[英]Missing color bar in ggplot with continuous scale and remote desktop

I am having the problem identified here , namely, on Windows (7) using remote desktop, plots with continuous color scales show up missing the scale.我在这里发现了问题,即在使用远程桌面的 Windows (7) 上,具有连续色标的图显示缺少标尺。 The solution at that link (increase color depth of remote desktop server) is infeasible for me as it's a shared server maintained by a corporate technology team and they aren't willing to change it.该链接的解决方案(增加远程桌面服务器的颜色深度)对我来说是不可行的,因为它是由公司技术团队维护的共享服务器,他们不愿意改变它。 I had hoped that saving the plot as a png without displaying it would solve the problem, but doing something like我曾希望将 plot 保存为 png 而不显示它可以解决问题,但是做类似的事情

p <- ggplot(...) ggsave(file='test.png', plot = p)

still fails.仍然失败。 Even though the plot is never displayed, it still has missing legend scale.即使 plot 从未显示,它仍然缺少图例比例。 The only workaround I've found is to save it as pdf, display the pdf (where the color bar is displayed) then use the Windows "snipping tool".我发现的唯一解决方法是将其另存为 pdf,显示 pdf(显示颜色条的位置),然后使用 Windows“截图工具”。 Obviously this is not an attractive solution for reproducibility.显然,对于再现性而言,这不是一个有吸引力的解决方案。 That is,那是,

p <- ggplot(...) ggsave(file='test.pdf', plot = p)

then displaying the file with, say, acrobat reader, then taking a screenshot, works.然后用 acrobat reader 显示文件,然后截屏,就可以了。 So the ggplot object p has the required data, but ggsave of a png file loses it when the display depth is 16 bit, even when the figure is saved without displaying.所以ggplot object p有需要的数据,但是当显示深度为16位时,png文件的ggsave会丢失它,即使图形保存而不显示也是如此。 (I need a png or jpg to insert in another doc.) (我需要一个 png 或 jpg 来插入另一个文档。)

Any suggestions appreciated.任何建议表示赞赏。

user12728748's suggestion solved the save-to-file problem. user12728748 的建议解决了保存到文件的问题。

An alternative, which is a partial solution to the original problem (being unable to see the color scale) is to modify the legend with something like:另一种方法是原始问题的部分解决方案(无法看到色标)是使用以下内容修改图例:

guides(fill = guide_legend(override.aes = list(size = 5)))

This replaces the continuous scale legend by an approximate discrete legend, but that is adequate for getting a rough idea of corresponding values.这用近似离散图例替换了连续比例图例,但这足以大致了解相应的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM