# Bubbles not lining up with correct state on Bubble map

**URL:** <https://community.plotly.com/t/bubbles-not-lining-up-with-correct-state-on-bubble-map/42332>\
**Category:** 📊 Plotly Python\
**Created:** [July 11, 2020, 2:55am UTC](https://community.plotly.com/t/bubbles-not-lining-up-with-correct-state-on-bubble-map/42332 "2020-07-11T02:55:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kioshi](https://avatars.discourse-cdn.com/v4/letter/k/7cd45c/32.png) [@kioshi](https://community.plotly.com/u/kioshi)\
**Post date:** [July 11, 2020, 2:55am UTC](https://community.plotly.com/t/bubbles-not-lining-up-with-correct-state-on-bubble-map/42332/1 "2020-07-11T02:55:56Z")

</div>

Hello,  
First time here and I read and looked at Plotyl’s code for producing US Bubble Maps, but ran into two issues.

1. The bubbles showing magnitudes are shifted and not showing in correct states, ie: Alaska is showing in Hawaii, California in Nevada, etc. How can I shift the bubbles or have them in the correct state?

2. How can I display only West and East Coast magnitudes and not all state magnitudes?

state\_max\_mag =

```auto
                   state latitude longitude mag
0 Alabama 34.7360 -85.629000 4.8
1 Alaska 71.1404 -131.232000 7.9
2 Arizona 36.9940 -109.058700 5.3
3 Arkansas 36.4400 -89.920000 5.0
4 California 41.9780 -115.366000 7.3

```

What I have so far:

```auto
every_earthquake = pd.read_csv('earthquake_states.csv')
fifty_state_quakes = every_earthquake[['state', 'latitude', 'longitude', 'mag']].dropna()
state_mag_max = pd.DataFrame(fifty_state_quakes, columns=['state', 'latitude', 'longitude', 'mag']).dropna()
state_max_mag_df = state_mag_max.groupby(['state'])['latitude', 'longitude','mag'].max().reset_index()
state_max_mag_df['text'] = state_max_mag_df['state'] + '<br>Magnitude ' + (state_max_mag_df['mag']).astype(str)
magnitude = [(0,1), (2,3), (4,5), (5,6), (7,8), (9, 10)]
colors = ['#E58606', '#5D69B1', '#52BCA3', '#99C945', '#CC61B0', '#24796C']
scale = 5

fig = go.Figure()

for i in range(len(magnitude)):

    magn = magnitude[i]

    state_max_mag_df1 = state_max_mag_df[(state_max_mag_df['mag'] >= magn[0]) & (state_max_mag_df['mag'] < magn[1])]

    fig.add_trace(go.Scattergeo(
    locationmode = 'USA-states',
    lon = state_max_mag_df1['longitude'],
    lat = state_max_mag_df1['latitude'],
    text = state_max_mag_df1['text'],
    marker = dict(
        size = state_max_mag_df1['mag'] * scale,
        color = colors[i],
        line_color = 'rgb(40,40,40)',
        line_width = 0.5,
        sizemode = 'diameter'),
    name = '{0} - {1}'.format(magn[0], magn[1])))

fig.update_layout(
  showlegend = True,
  geo = dict(scope = 'usa', landcolor = 'rgb(217, 217, 217)')
)

fig.show()

```

result:

 ![newplot (3)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/1/1925b59e04b5e07fb9bc9f93ff638e9c7b825921.png)

I would like the bubbles to correspond to correct state boundaries like in Plotly’s bubble map:

 ![newplot](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/2/245fc2071ebbd3e5432fbb8ab5766ec9d0f7bee8.png)

Thank you
