title: ggplot2 producing different outputs with the exact same code
body: <p>I am working on a visualization to implement in shiny. For now, I just want to make it work so that everyone can host the app on their own computer. While testing I have noticed that ggplot2 produces a different output on different computers, with the same code. Both computers run R3.6.1 and ggplot2 is installed and run the same way (see below). Both of them have German as the default language and run Windows 10.</p>
  <p><strong>I need to understand why there is a difference and how to write a code that produces the same output on multiple computers.</strong></p>
  <p>This is the desired output that works on the computer I used to write the code: <a href="https://i.stack.imgur.com/bkdw4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bkdw4.png" alt="desired output" /></a></p>
  <p>I cannot give you the exact code for the desired output as there are data cleaning functions involved. I have therefore made a self contained example, that uses the exact same data as the desired output. The code and the data is the exact same (only the dataframes are made manually in the example), but the output is different.</p>
  <p>This is the output I get from running the example code (see below) on one of the computers:</p>
  <p><a href="https://i.stack.imgur.com/WAwD1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WAwD1.png" alt="example code on computer 1" /></a></p>
  <p>As you can see ggplot2 has flipped the data and puts the wrong part to the bottom.</p>
  <p>This is the one I get from running the code on the other computer:</p>
  <p><a href="https://i.stack.imgur.com/98DO4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/98DO4.jpg" alt="example code on computer 2" /></a></p>
  <p>Flipping still stays, but the colors have changed.</p>
  <p>The self contained code (the desired output is the same, apart from the dataframes are made with cleaning functions):</p>
  <pre><code>if (!require(&quot;tidyverse&quot;)) install.packages(&quot;tidyverse&quot;); library(&quot;tidyverse&quot;)
  if (!require(&quot;sjmisc&quot;)) install.packages(&quot;sjmisc&quot;); library(&quot;sjmisc&quot;)
  if (!require(&quot;shiny&quot;)) install.packages(&quot;shiny&quot;); library(&quot;shiny&quot;)
  if (!require(&quot;shinyWidgets&quot;)) install.packages(&quot;shinyWidgets&quot;); library(&quot;shinyWidgets&quot;)
  if (!require(&quot;gt&quot;)) install.packages(&quot;gt&quot;); library(&quot;gt&quot;)
  if (!require(&quot;dplyr&quot;)) install.packages(&quot;dplyr&quot;); library(&quot;dplyr&quot;)
  if (!require(&quot;webshot&quot;)) install.packages(&quot;webshot&quot;); library(&quot;webshot&quot;)
  if (!require(&quot;ggplot2&quot;)) install.packages(&quot;ggplot2&quot;); library(&quot;ggplot2&quot;)
  if (!require(&quot;processx&quot;)) install.packages(&quot;processx&quot;); library(&quot;processx&quot;)
  #packages are necessary for other parts of the code, I include them here as they might have something to do with the weird behaviour
  
  
  data &lt;- data.frame(&quot;value&quot;=c(43.5,45.6,59.4,48.1,56.5,54.4,40.6,51.9), &quot;type&quot;=c(&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;c&quot;,&quot;r&quot;,&quot;r&quot;,&quot;r&quot;,&quot;r&quot;), &quot;cat&quot;=c(&quot;e_rating&quot;, &quot;s_rating&quot;, &quot;g_rating&quot;, &quot;esg_rating&quot;,&quot;e_rating&quot;, &quot;s_rating&quot;, &quot;g_rating&quot;, &quot;esg_rating&quot;))                    
  imed &lt;- data.frame(&quot;value&quot;=c(37.8,40.9,55.8,43.0), &quot;type&quot;=c(&quot;m&quot;,&quot;m&quot;,&quot;m&quot;,&quot;m&quot;), &quot;cat&quot;=c(&quot;e_rating&quot;, &quot;s_rating&quot;, &quot;g_rating&quot;, &quot;esg_rating&quot;) )
  ihigh &lt;- data.frame(&quot;value&quot;=c(62.3,71.5,78.6,69.0), &quot;type&quot;=c(&quot;m&quot;,&quot;m&quot;,&quot;m&quot;,&quot;m&quot;), &quot;cat&quot;=c(&quot;e_rating&quot;, &quot;s_rating&quot;, &quot;g_rating&quot;, &quot;esg_rating&quot;) )
  imin &lt;-  data.frame(&quot;value&quot;=c(15.7,19.0,17.4,17.2), &quot;type&quot;=c(&quot;m&quot;,&quot;m&quot;,&quot;m&quot;,&quot;m&quot;), &quot;cat&quot;=c(&quot;e_rating&quot;, &quot;s_rating&quot;, &quot;g_rating&quot;, &quot;esg_rating&quot;) )
  
  
  ggplot() +
    geom_bar(data = data,aes(x=cat, y=value, fill=type),stat = &quot;identity&quot;, width = 0.35) +
    geom_point(aes(x=imed$cat, y=imed$value ,shape = &quot;1&quot;),  size = 5, fill = &quot;#000000&quot;) + 
    geom_point(aes(x=ihigh$cat, y=ihigh$value, shape = &quot;2&quot;),  size = 4, fill = &quot;#000000&quot;) +
    geom_point(aes(x=imin$cat, y=imin$value, shape = &quot;3&quot;), size = 4, fill = &quot;#000000&quot;) +
    scale_fill_manual(values=c(&quot;#FBF315&quot;,&quot;#FF0000&quot;), breaks = c(&quot;c&quot;), labels = &quot;Company&quot;) +
                        scale_shape_manual(values=c(19, 24,25),labels=c(&quot;Industry median&quot;, &quot;High&quot; ,&quot;Low&quot;)) +
                        scale_x_discrete(labels=c(&quot;E&quot;, &quot;S&quot;, &quot;G&quot;, &quot;ESG&quot;)) +
                        theme(panel.background = element_blank(),
                              panel.grid.major.y = element_line(color=&quot;#D4D4D4&quot;,size=1),
                              aspect.ratio = 1,
                              legend.title= element_blank(),
                              legend.direction = &quot;horizontal&quot;,
                              legend.box = &quot;horizontal&quot;,
                              legend.position = &quot;bottom&quot;,
                              axis.title = element_blank()) +
                        guides(shape = guide_legend(override.aes = list(size = 3))) 
  </code></pre>
  <p>The data I use in the examples is the same as the output from the cleaning functions, here is proof:
  <a href="https://i.stack.imgur.com/FgGi3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FgGi3.png" alt="the data is the same" /></a></p>
  <p><em>Actually I might have gone down on the wrong path entirely, as I don´t actually need a stacted barchart, I just need to show that 100 is the maximum. So the yellow part on the desired output could also be a &quot;column background&quot; or something like that. Unfortunately, I could not find anything else but this method.</em></p>
  <p>Thank you for your help!</p>