Tips for minimizing excess white space in Shiny applications

Encountering an issue with plot output in Shiny. When using standard ggplots, the output is correct without any extra white margins. However, when utilizing the "ggmap" package (which also produces ggplot-type outputs), white margins suddenly appear.

(Please disregard any Polish words as they are not pertinent) !Example:

Code: ui.R

    shinyUI(fluidPage(
  fluidRow(class="row2",
           tags$head(
             tags$style("body {background-color: #94BEE8; height: 600px}")
           ),
           column(
             h3("Filters"),
             dateInput("date", label=h5("Date"), value = "2014-09-07", min = "2014-09-01", max="2014-09-14"),
             sliderInput("hour", label=h5("Hour"), min = 0, max = 23, value = 15, animate= TRUE),
             textInput("text1", label=h5("Address I"), value="Piotrkowska 30, Lodz"),
             textInput("text2", label=h5("Address II"), value = "Uniwersytecka 5, Lodz"),
             numericInput("radius", label=h5("Radius [km]"), value = 1, min = 0.1, max = 100),
             sliderInput("zoom", label="", min =1, max = 21, value = 13),
             submitButton(text="Enter Data"),
             width = 2),
           column(5,
                  div(plotOutput("map", width = "100%")
                      , style = "height: 300px; background-color: #94BEE8;")
           ),
           column(5,
                  htmlOutput("table")
           ))
  ))

Part of server.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=address1, aes(x=lon, y=lat), size=15, col = "blue", alpha = 0.35)+
        geom_point(data=address2, aes(x=lon, y=lat), size =15, col ="red", alpha=0.35)+
       xlab("")+ylab("")+ggtitle("TITLE")+
        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="CONNECTION COUNT")
  plot(p)
    }, width=500, height=500)

Issue 2. Facing difficulty in adding a rectangle or circle with a 2km radius to a ggmap object.

Appreciate any assistance provided.

Answer №1

Resolved with the help of

+coord_fixed(ratio = 1.45)

While not completely accurate, this solution gets the job done.

The subsequent issue was tackled by utilizing geom_polygon(). I couldn't figure out why it wasn't functioning properly before.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble toggling journal entries in an HTML journal? The Jquery function might not be working properly

I have been tasked with creating a civil war journal for my 8th grade Social Studies class and I decided to present it as an HTML file featuring the title and date of each journal entry. The goal is to allow users to click on each entry to open it while au ...

The functionality of CSS isn't up to snuff on Mozilla Firefox

I am having an issue with CSS styling on a <div> element in my PHP page. The CSS style is working perfectly in Google Chrome, but when I test my code in Firefox, the styling is not being applied. .due-money { background-color: #09C; color: whi ...

Tips for creating zoomed-in background images on small screens

I am currently implementing this code for a website project .homepage{ background-image: url(/wp-content/themes/ep/img/_.png); -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; background ...

React-Tooltip trimming

Currently, I am facing a dilemma that requires some resolution. The issue at hand is related to the placement of React-Tooltip within the List element. Whenever it's positioned there, it gets clipped. On the other hand, placing it at the bottom isn&a ...

Ensure that the fixed header's width matches the size of the container div

The header element is contained within a div. I have positioned the header as fixed, leading to 2 issues: The width of the header extends beyond the width of the div container. It should align with the div. When the header is fixed, the other elements li ...

Issues of horizontal spaces in HTML emails

We have been facing an ongoing issue with the layout of our email communications. Upon rendering in Outlook, the emails are displaying additional horizontal gaps/spaces. However, the web version of the email appears to be fine. It's unclear to us the ...

There appears to be an empty void on the website

If you could kindly click on this link & use CTRL + F to search for the text "Info", you will see a visual representation similar to the image below. There seems to be quite a bit of empty space below these texts. I experimented with padding, display: ...

Knitr is throwing a Namespace Error: Unable to knit to PDF or any other format

I'm attempting to generate a PDF export of my R outputs, which include tables and graphs. I've created a .Rmd document and when trying to run a simple code to set up the document, I encounter an error right away. The same error occurs when I clic ...

Pressing a button is a way to select a specific form

I'd like to create a clickable button that can direct users to the form section on the same page. <button type="button" class="btn btn-primary btn-sm"> Go to Form Section </button> ... <form id="form1"> <div class="form-g ...

A guide to correcting alignment issues on a flex box containing both images and text

I am encountering a problem with my flexbox setup. It contains multiple products with images and text, but the issue arises when a product has more than one line of text causing the image to be slightly raised compared to others. Any suggestions on how to ...

I am having trouble with the Bootstrap 5 column not functioning properly within my design

Currently working on a project with Bootstrap, where I am trying to create a footer that looks like the one in the image below: https://i.stack.imgur.com/XIbDk.png Below is the HTML code snippet for my footer: <footer class="footer"> <div class ...

Tips for aligning two elements in a row using Bootstrap 4 Flex

I am facing a challenge with positioning an H2 element and a Dropdown button on the same line using bootstrap 4 flex. Here is what I have: https://i.sstatic.net/kV45k.png This is what I am trying to achieve: https://i.sstatic.net/Owt5j.png Below is my ...

jQuery: Extracting text labels from checkboxes

My custom select dropdown includes checkboxes that are hidden until the user clicks on the dropdown: ---Select---- -option1- -option2- -option3- When a user clicks on the Select, the options appear as checkboxes. I want to be able to retrieve the labels ...

Is there a way to instruct the program "Unite" to recognize and locate my variable names?

I have a collection of English classes from various time periods that share the same content. My goal is to merge these classes into a single column. Here is what I have tried: test5<-unite(test5,"ENGELSKA",c("MARKEN200","MARKENGENG05","MARKEN1201")) ...

what distinguishes CSS properties for Id versus class selectors

Currently in the process of creating my inaugural website, which consists of just four pages. Each page follows the standard layout structure with a header, navigation bar, content division (div id="content"), and footer. As I delve into adding CSS proper ...

Enter various data points from the beginning to the conclusion of the range

I have a question similar to the one discussed in this thread: Fill in values between start and end value in R The difference in my case is that I need to fill in values between the start and end of multiple values without an ID column: This is how my da ...

What strategies can be implemented to enhance the performance of this jQuery slider?

I have successfully created an image carousel. Encountered Challenges: The last slide is displayed, but the counter shows the first slide. How can I resolve this issue? When clicking play, it continues to advance the count. Is there a way to make it ...

Changing the Title of UI Tabs

I am facing an issue with setting the title in tabs, as the title is appearing behind the background. If I set background: transparent; in the #tabss .ui-tabs-nav class, then my title shows up properly. Otherwise, it gets displayed behind the background. ...

Displaying a success dialog after closing a Bootstrap modal

I have set up a bootstrap modal containing a form. Upon submitting the form, the form content is hidden and a bootstrap alert message is displayed. However, upon clicking the bootstrap popup, the same alert message is shown in the popup instead of displayi ...

Stack div on top of div

It seems like I'm facing a simple problem that needs a solution. I have two container divs .topwrap{ position:relative; top:100px; background:#00C; } </i> and .lowerwrap{ position:relative; ...