Skip to content

[Feature Request | Bug Report] Plot Area / Colorbar Size Variance (Geos) #3288

Description

@tony-zeidan

Hi there,

I am using Plotly for an application of mine and I am having trouble matching the size of the color bar to the size of the plot area itself. I want my code to do this automatically.

I am using the Plotly graph objects API in order to do this.

I am noticing variance in the size of the plot area which doesn't let me modify the color bar properties in my code easily.

I believe this plot area size variance to be a bug? If we could change the size of the plot area independently from the figure size, that would be an excellent feature as well.

I have an example of this variance using GeoPandas, which I tried to make as short as possible:

from plotly.graph_objs import Choropleth, Figure
import geopandas as gpd
import json

gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
gdf['value_field'] = 0

# first figure: hone in on canada
canada_gdf = gdf[gdf['name'] == 'Canada']
choro = Choropleth(geojson=json.loads(canada_gdf.to_json()), z=canada_gdf['value_field'], locations=canada_gdf.index)

fig = Figure()
fig.update_layout(margin=dict(b=5, t=5, l=5, r=5), height=600, width=800)
fig.add_trace(choro)
fig.update_geos(projection_type='orthographic', lataxis_range=[40, 90], lonaxis_range=[-145, - 50], projection_rotation=dict(lat=62, lon=-96))
fig.show()

# second figure: hone in on france
france_gdf = gdf[gdf['name'] == 'France']
choro = Choropleth(geojson=json.loads(france_gdf.to_json()), z=france_gdf['value_field'], locations=france_gdf.index)

fig = Figure()
fig.update_layout(margin=dict(b=5, t=5, l=5, r=5), height=600, width=800)
fig.add_trace(choro)
fig.update_geos(projection_type='orthographic', lataxis_range=[40, 60], lonaxis_range=[-10, 20], projection_rotation=dict(lat=46, lon=2.5))
fig.show()

Canada image:
image

France image:
image

Any help concerning how to do this automatically or even a formula to calculate would also be greatly appreciated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions