title: How to create full scale colorbar for single value data using tmap?
body: <p>I need to generate different maps using <code>tmap</code>. To create a continous colorbar I use
  <code>style = &quot;cont&quot;</code> together with defined breaks (<code>breaks = seq(0, 100, 25))</code>).</p>
  <p>This works well if my data shows some variation (see map 1 below). However, I also have data for which there is no variation across the individual polygons (see map 2). Nevertheless, to allow for direct comparison I want to have the colorbar plotted for map 1 (full range between 0 and 100) also for map 2.</p>
  <p>So far I found no solutions to fix that problem. Any ideas?</p>
  <pre><code>library(tidyverse)
  library(tmap)
  library(sf)
  library(urbnmapr)
  
  makeMap &lt;- function(data){
    tm_shape(data) +
    tm_fill(&quot;par&quot;,
            palette = &quot;RdYlGn&quot;,
            style = &quot;cont&quot;,
            breaks = seq(0, 100, 25)) +
    tm_layout(legend.text.size = 1.5,
              legend.bg.color = &quot;white&quot;,
              legend.bg.alpha = .8) +
    tm_borders(lwd = 1, col = &quot;black&quot;)
  }
  
  # map 1
  states_sf1 &lt;- get_urbn_map(&quot;states&quot;, sf = TRUE) %&gt;%  
    as.tibble() %&gt;% 
    mutate(par = runif(51, 0 ,100)) %&gt;% 
    st_as_sf() 
  
  makeMap(states_sf1)
  
  # map 2
  states_sf2 &lt;- get_urbn_map(&quot;states&quot;, sf = TRUE) %&gt;%  
    as.tibble() %&gt;% 
    mutate(par = 10) %&gt;% 
    st_as_sf() 
  
  makeMap(states_sf2)
  </code></pre>
  <p><strong>Map 1</strong></p>
  <p><a href="https://i.stack.imgur.com/jvOOF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jvOOF.png" alt="enter image description here" /></a></p>
  <p><strong>Map 2</strong></p>
  <p><a href="https://i.stack.imgur.com/sp6jq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sp6jq.png" alt="enter image description here" /></a></p>