title: Plotly: How to set a manual bounding box for a Scattergeo?
body: <p>I'm trying to calculate the mean center of population in the U.S. for a variety of variables, so my first step was to compute them for the last 10 years of population by county and see if they match up against the <a href="https://www.census.gov/dataviz/visualizations/050/" rel="nofollow noreferrer">Census maps</a> of this figure (at least roughly, since the Census is using a more granular geographic resolution.) As you'd expect, it's a sort of extremely delayed Manifest Destiny:</p>
  <p><a href="https://i.stack.imgur.com/gZ89zm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gZ89zm.png" alt="enter image description here" /></a></p>
  <p>(The formula for calculating these points based on many population centers is <a href="https://www.census.gov/2010census/news/pdf/cop2010_documentation1.pdf" rel="nofollow noreferrer">on page 2 here</a>, if anyone is curious.)</p>
  <p>I'm migrating from R/RStudio to Jupyter, using pandas, plotly, numpy, etc. I'm normally a JavaScript engineer, but I'm comfortable with Python and like it quite a bit more than R! I was able to calculate what appear to be similar points, using the airport map example in this <a href="https://plotly.com/python/scatter-plots-on-maps/" rel="nofollow noreferrer">fantastic tutorial on <code>plotly.graph_objects.Scattergeo</code></a>, but I'm stuck at a national resolution so I can't tell how well I'm doing:</p>
  <p><a href="https://i.stack.imgur.com/BCVrtm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BCVrtm.png" alt="enter image description here" /></a></p>
  <p>I can manually zoom, of course, but I'd really like to understand how to focus on only Missouri by default. I found this <a href="https://codepen.io/etpinard/pen/XKamdk" rel="nofollow noreferrer">useful CodePen</a>, but since there are so many different excellent mapping tools in Python I'm not sure how to port over the JS.</p>
  <p>My current map, based on the above tutorial, sets up the basic plot and then modifies the layout's scope in a second line -- I'm not certain if this is standard for <code>plotly</code>, or just a convenience.</p>
  <p>As much as I admire Python, going straight to the docs for <code>update_layout</code> is a bit of a rabbit hole :) I don't mind dictating the lat/lng bounds of the viewport, though it would neat to just say &quot;Missouri.&quot; I realize this is simple -- just a bit of a learning curve.</p>
  <pre><code>import pandas as pd
  import plotly.graph_objects as go
  
  meanCenters = pd.read_json('{&quot;year&quot;: {&quot;0&quot;: 2010, &quot;1&quot;: 2011, &quot;2&quot;: 2012, &quot;3&quot;: 2013, &quot;4&quot;: 2014, &quot;5&quot;: 2015, &quot;6&quot;: 2016, &quot;7&quot;: 2017, &quot;8&quot;: 2018, &quot;9&quot;: 2019}, &quot;lat&quot;: {&quot;0&quot;: 37.52908501121699, &quot;1&quot;: 37.51719645600817, &quot;2&quot;: 37.50264465332917, &quot;3&quot;: 37.489564543614605, &quot;4&quot;: 37.47311004581999, &quot;5&quot;: 37.45358003505096, &quot;6&quot;: 37.43623735876329, &quot;7&quot;: 37.423475510154134, &quot;8&quot;: 37.4121869670822, &quot;9&quot;: 37.40021167050047}, &quot;lng&quot;: {&quot;0&quot;: -92.1522086893934, &quot;1&quot;: -92.17800419530532, &quot;2&quot;: -92.20484620692078, &quot;3&quot;: -92.23312370193283, &quot;4&quot;: -92.26617930383293, &quot;5&quot;: -92.30498885605378, &quot;6&quot;: -92.3395596061908, &quot;7&quot;: -92.36398254029461, &quot;8&quot;: -92.38362683728195, &quot;9&quot;: -92.40337680455285}}')
  
  fig = go.Figure(data=go.Scattergeo(
      lon = meanCenters['lng'],
      lat = meanCenters['lat'],
      mode = 'markers'
  ))
  fig.update_layout(
      geo_scope='usa',
      height=600
  )
  fig.show()
  </code></pre>
  <p>Data is included above -- thx, @vestland! -- but reprinted here for readability</p>
  <pre><code>year    lat lng
  2010    37.52908501121699   -92.1522086893934
  2011    37.51719645600817   -92.17800419530532
  2012    37.50264465332917   -92.20484620692078
  2013    37.489564543614605  -92.23312370193283
  2014    37.47311004581999   -92.26617930383293
  2015    37.45358003505096   -92.30498885605378
  2016    37.43623735876329   -92.3395596061908
  2017    37.423475510154134  -92.36398254029461
  2018    37.4121869670822    -92.38362683728195
  2019    37.40021167050047   -92.40337680455285
  </code></pre>