How to manually set window ranges with mercator GPS plot?

Hi, I wonder if theres a good solution for changing the y_range and x_range of a gps plot.

If I set the x- and y_ranges based on an area I want to show (eg. an area containing all my points in a dataset), there is a wrong spect ratio, which of course makes sense, due to the mercator projection.
If I zoom in and the next higher “zoom-level tile” is loaded, the aspect ration “snaps” to the correct one.
However, I want to have an optimal view right at the beginning, since in some cases, I wont touch the plots, but save them as a file directly.

fig_map = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
                x_axis_type="mercator", y_axis_type="mercator")
tile_provider = get_provider(CARTODBPOSITRON_RETINA)

# somewhere later: This causes a wrong stretching of the map until I manually zoom in.
fig_map.y_range.start = df['Latitude'].min()
fig_map.y_range.end = df['Latitude'].max()
fig_map.x_range.start = df['Longitude'].min()
fig_map.x_range.end = df['Longitude'].max()

Is there a way to somehow pad the axis range to the correct map aspect ratio (which to my understanding should be dependent on the current Latitude value range of the plot)?

match_aspect = True is what you’re looking for I think.

See Keep a fixed aspect ratio when zooming with box tool - #2 by Bryan for some decent discussion :slight_smile:

1 Like