How to apply custom theme to bubble chart

Hey there, actually I gave you the answer right here:

Applied to the new axis ranges:

import plotly.graph_objects as go
import plotly.express as px 
import pandas as pd


data = {'x': [1.5, 1.6, -1.2],
        'y': [21, -16, 46],
        'circle-size': [10, 5, 6],
        'circle-color': ["red","blue","green"]
        }

# Create DataFrame
df = pd.DataFrame(data)
fig = px.scatter(
    df,
    x="x", 
    y="y", 
    color="circle-color",
    size='circle-size'
)


fig.update_layout(
    {
        'xaxis': {
            "range": [-100, 100],
            'zerolinewidth': 3, 
            "zerolinecolor": "blue",
            "tick0": -100,
            "dtick": 25,
            'scaleanchor': 'y'
        },
        'yaxis': {
            "range": [-100, 100],
            'zerolinewidth': 3, 
            "zerolinecolor": "green",
            "tick0": -100,
            "dtick": 25
        },
        "width": 500,
        "height": 500
    }
)

fig.add_scatter(
    x=[0, 0, -100, -100],
    y=[0, 100, 100, 0],
    fill="toself",
    fillcolor="rgba(38,230,0,0.5)",
    zorder=-1,
    mode="markers",
    marker_color="rgba(0,0,0,0)",
    showlegend=False,
    hoverinfo="skip"
)
fig.add_scatter(
    x=[0, 0, 100, 100],
    y=[0, -100, -100, 0],
    fill="toself",
    fillcolor="rgba(229,230,0,0.5)",
    zorder=-1,
    mode="markers",
    marker_color="rgba(0,0,0,0)",
    showlegend=False,
    hoverinfo="skip"
)

fig.show()

2 Likes