Ggplot 轴标签未以闪亮方式显示

问题描述 投票:0回答:2

我对 Shiny 很陌生,对在 Shiny 中绘图完全陌生,并且在使用 ggplot 时遇到了绘图轴标签的问题。当我运行应用程序时,它们只是不显示。如果之前有人问过这个问题,我深表歉意,我发誓在提问之前我确实搜索过答案:-)

这是一个超级简化的 ggplot 示例,但对我不起作用:

ui = fluidPage(
  sidebarLayout(
    sidebarPanel(
    ),
    mainPanel(
      plotOutput("plot"),
      plotOutput("ggplot")
    )
  )
)

server = function(input, output) {
  
  output$plot <- renderPlot({
    plot(cars)
  })
  
  output$ggplot <- renderPlot({
    ggplot(cars) +
      geom_point(mapping = aes(x = speed, y = dist))
  })
  
}

shinyApp(ui = ui, server = server)

这是我得到的输出: Output while running the app

如您所见,带有

plot
的图有轴标签,但 ggplot 没有。

我做错了什么? :-)

谢谢!

ggplot2 shiny label axis
2个回答
1
投票

当我将带有 Apple M2 芯片的 Macbook Pro 连接到外部显示器时遇到类似问题(内部屏幕上显示闪亮的 ggplot2 图例,但将窗口拖动到外部显示器时则不会),我通过安装此工具解决了该问题: https://github.com/waydabber/BetterDisplay.


0
投票

我在 Intel mac 上也遇到了同样的问题。安装 Better Display 应用程序并通过强制 HiDPi 将外部显示器的设置更改为较低的宽高比修复了此问题。因此,在应用程序中输入显示模式,然后转到外接显示器的设置。过滤以包括 HiDPi,默认宽高比 1920 x 1080 会下降,唯一可用的 16:9 是 1280 x 720。选择此选项,绘图文本将在外部监视器上以闪亮的形式显示。外接显示器默认为 16:9,因此强制匹配视网膜 16:10 可以提供 1920 x 1200 的选项,但效果不太好。我暂时坚持使用 1280 x 720 只是为了方便,虽然不理想但可行,直到我得到匹配的视网膜显示器

© www.soinside.com 2019 - 2024. All rights reserved.