# A custom layout for Barpolar in Plotly/Dash

**URL:** <https://community.plotly.com/t/a-custom-layout-for-barpolar-in-plotly-dash/88181>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [October 23, 2024, 12:29pm UTC](https://community.plotly.com/t/a-custom-layout-for-barpolar-in-plotly-dash/88181 "2024-10-23T12:29:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![loomaisand](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@loomaisand](https://community.plotly.com/u/loomaisand)\
**Post date:** [October 23, 2024, 12:29pm UTC](https://community.plotly.com/t/a-custom-layout-for-barpolar-in-plotly-dash/88181/1 "2024-10-23T12:29:36Z")

</div>

Hi community,

I am trying to figure out a change in a barpolar plot layout. I have included the example (below) where I would like to change the left plot layout to the one on the right:

 ![example](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/b/c/bc1ee742f21f93c3f0fea65b567c258f3f9fef5d.jpeg)

I have also included a reproducible code example for the left plot:

```auto

rs = [10, 20, 30, 40, 50, 60, 70, 80]
thetas= ["B_right", "A2", "A1", "A3", "B_left","C1", "C2", "C3"]
fills = ["red", "red", "grey", "blue", "red", "grey", "blue", "red"]

fig = go.Figure()
fig.add_trace(
    go.Barpolar(
        r=rs,
        theta=thetas,
        marker_color=fills
    )
)

```

Any ideas how to achieve the right plot’s layout? I would like the bar of A fill the entire “designated” area (i.e., along the vertical axis of A) and preserve the shape of the plot.

Thanks!

---

<div class="post-metadata">

**Author:** ![farispriadi](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/farispriadi/32/26759_2.png) [@farispriadi](https://community.plotly.com/u/farispriadi)\
**Post date:** [October 24, 2024, 3:37pm UTC](https://community.plotly.com/t/a-custom-layout-for-barpolar-in-plotly-dash/88181/2 "2024-10-24T15:37:44Z")

</div>

Hi @loomaisand ,

As I understand what you mean.

You need to change `theta` value with list of degrees where the bar will be positioned.

After doing that the delta theta will not the same, and you can set custom `width` of each bar to make certain bar wider.

```auto
fig.update_traces(
                    r=[10, 90, 50, 60, 70, 80],
                    # set theta as degrees
                    theta = [0,90,180,225,270,315],
                    # set color of each bar
                    marker_color= ["red", "red", "red", "grey", "blue", "red"],
                    # set custom width of each bar
                    width=[40, 120, 40, 40, 40, 40],
                    selector=dict(type='barpolar'))

```

Replace the tick from degrees to text with `update_layout`

```auto
fig.update_layout(
    polar=dict(
        angularaxis=dict(
            # set custom tick 
            tickvals=[0,90,180,225,270,315],
            # set custom tick text
            ticktext=["B_right", "A", "B_left","C1", "C2", "C3"]
        )
    )
)

```

Here is the code, when you put together:

```auto
import plotly.graph_objects as go 

rs = [10, 20, 30, 40, 50, 60, 70, 80]
thetas= ["B_right", "A2", "A1", "A3", "B_left","C1", "C2", "C3"]
fills = ["red", "red", "grey", "blue", "red", "grey", "blue", "red"]

fig = go.Figure()
fig.add_trace(
    go.Barpolar(
        r=rs,
        theta=thetas,
        marker_color=fills
    )
)

fig.update_traces(
                    r=[10, 90, 50, 60, 70, 80],
                    # set theta as degrees
                    theta = [0,90,180,225,270,315],
                    # set color of each bar
                    marker_color= ["red", "red", "red", "grey", "blue", "red"],
                    # set custom width of each bar
                    width=[40, 120, 40, 40, 40, 40],
                    selector=dict(type='barpolar'))

fig.update_layout(
    polar=dict(
        angularaxis=dict(
            # set custom tick 
            tickvals=[0,90,180,225,270,315],
            # set custom tick text
            ticktext=["B_right", "A", "B_left","C1", "C2", "C3"]
        )
    )
)

fig.show()

```

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/4/0/40b3d7816905c2b3afd0204b18a90f17e53da975.png)

---

<div class="post-metadata">

**Author:** ![loomaisand](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@loomaisand](https://community.plotly.com/u/loomaisand)\
**Post date:** [October 25, 2024, 11:59am UTC](https://community.plotly.com/t/a-custom-layout-for-barpolar-in-plotly-dash/88181/3 "2024-10-25T11:59:41Z")

</div>

Thanks @farispriadi - works as expected!
