【问题标题】:How to reduce white margins in Shiny如何减少 Shiny 中的白边距
【发布时间】:2014-11-19 08:00:29
【问题描述】:

我在 Shiny 中的绘图输出有问题。使用标准 ggplots 我有正确的输出,意味着没有额外的白色边距,但是当我使用“ggmap”包(输出也是 ggplot 类型)时出现白色边距

(忽略波兰语,不重要) !例子:

代码:ui.R

    shinyUI(fluidPage(
  fluidRow(class="row2",
           tags$head(
             tags$style("body {background-color: #94BEE8; height: 600px}")
           ),
           column(
             h3("Filtry"),
             dateInput("date", label=h5("Data"), value = "2014-09-07", min = "2014-09-01", max="2014-09-14"),
             sliderInput("godz", label=h5("Godzina"), min = 0, max = 23, value = 15, animate= TRUE),
             textInput("text1", label=h5("Adres I"), value="Piotrkowska 30, Lodz"),
             textInput("text2", label=h5("Adres II"), value = "Uniwersytecka 5, Lodz"),
             numericInput("r", label=h5("Promień [w km]"), value = 1, min = 0.1, max = 100),
             sliderInput("zoom", label="", min =1, max = 21, value = 13),
             submitButton(text="Wprowadź dane"),
             width = 2),
           column(5,
                  div(plotOutput("mapa", width = "100%")
                      , style = "height: 300px; background-color: #94BEE8;")
           ),
           column(5,
                  htmlOutput("tabela")
           ))
  ))

服务器的一部分。R

 # Plotting
    g <- p+
        geom_point(data = data, aes(x = LONGITUDE, y = LATITUDE, size = LICZBA.NUMEROW), col = "yellow")+
        geom_point(data= data, aes(x=LONGITUDE, y=LATITUDE, size = (0.625)*LICZBA.NUMEROW), col ="black", alpha = 0.4)+
        geom_point(data=adres1, aes(x=lon, y=lat), size=15, col = "blue", alpha = 0.35)+
        geom_point(data=adres2, aes(x=lon, y=lat), size =15, col ="red", alpha=0.35)+
       xlab("")+ylab("")+ggtitle("TYTUŁ")+
        theme(
          legend.position = "bottom",
          legend.title=element_text(""),
          legend.key = element_rect(colour = "black"),
          legend.background = element_rect(fill="#94BEE8"),
          plot.background = element_rect(fill = "#94BEE8", colour = 'red')
          )+scale_colour_discrete(name="LICZBA POŁĄCZEŃ")
  plot(p)
    }, width=500, height=500)

问题 2。 我在向 ggmap 对象添加矩形或圆形时遇到问题,例如半径为 2 公里。

提前感谢您的帮助。

【问题讨论】:

    标签: css r shiny


    【解决方案1】:

    通过使用解决

    +coord_fixed(ratio = 1.45)
    

    这不是准确的答案,但工作正常。

    我通过应用geom_polygon()解决了第二个问题。我不知道为什么它最近不工作。

    【讨论】:

      猜你喜欢
      • 2021-04-11
      • 2014-10-05
      • 1970-01-01
      • 2018-06-18
      • 1970-01-01
      • 2011-05-01
      • 2012-11-01
      • 1970-01-01
      相关资源
      最近更新 更多