# Radar chart - fill between based on a condition

**URL:** <https://community.plotly.com/t/radar-chart-fill-between-based-on-a-condition/72673>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [February 14, 2023, 9:20am UTC](https://community.plotly.com/t/radar-chart-fill-between-based-on-a-condition/72673 "2023-02-14T09:20:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![simone\_p](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@simone\_p](https://community.plotly.com/u/simone_p)\
**Post date:** [February 14, 2023, 9:20am UTC](https://community.plotly.com/t/radar-chart-fill-between-based-on-a-condition/72673/1 "2023-02-14T09:20:14Z")

</div>

Dear all,

I am trying to create a radar chart with colouring based on a condition.  
I am taking inspiration from this post on [StackOverflow](https://stackoverflow.com/questions/64741015/plotly-how-to-color-the-fill-between-two-lines-based-on-a-condition) but couldn’t implement it properly.  
The condition shown here is a color property based on ‘res’: [red \< 0 \< green].  
Below, I add a code snippet of what worked so far with ‘fillcolor’, and a possible expected result.

```auto
import plotly.graph_objects as go
import plotly.io as pio
pio.templates.default = "plotly_white"

r=[0, 0, 0, 0, 0, 0]
theta=['Property 1', 'Property 2', 'Property 3', 'Property 4', 'Property 5', 'Property 6', 'Property 1'] 
res = [0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5]
color_s = 'rgba(125, 125, 125, 0.4)'

fig = go.Figure()
fig.add_trace(go.Scatterpolar(r=[0, 0, 0, 0, 0, 0, 0], theta=theta, fill=None, name='T-Score'))
fig.add_trace(go.Scatterpolar(r=res, theta=theta, fill='tonext', line_color=color_s, fillcolor=color_s, name='Data'))
fig.update_layout(polar=dict(radialaxis=dict(visible=True, range=[-1, 1])), width=500, height=500, title_text="Radar chat with color", title_x=0.5)
fig.update_traces()
fig.show()

```

**Current result:**  
 ![RadarNoColor](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/a/3/a352bd696ad8e713069fb117cbeb5a6e305d385b.png)

**Expected result:**  
 ![RadarChartColor](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/6/3/638ad38419df28b1e4ad06b1353a85d8bfbafa62.png)

Any help or workaround would be much appreciated!  
Best,  
Simone

---

<div class="post-metadata">

**Author:** ![empet](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@empet](https://community.plotly.com/u/empet)\
**Post date:** [February 14, 2023, 8:12pm UTC](https://community.plotly.com/t/radar-chart-fill-between-based-on-a-condition/72673/2 "2023-02-14T20:12:49Z")

</div>

Hi @simone_p,  
To assign different colors to the two regions, some computations are needed, but with your settings they are impossible, because in mathematics the polar radius cannot be negative. If you reference all points involved in your figure to a polar system with origin at 0, i.e. with the following code:

```auto
import plotly.graph_objects as go

color_s = 'rgba(125, 125, 125, 0.4)'
fig = go.Figure()
fig.update_layout(polar=dict(radialaxis=dict(visible=True, range=[0, 2])), 
                  template="plotly_white",
                  width=450, height=450#, title_text="Radar chart with color", title_x=0.5
                 )
theta=['Property 2', 'Property 3', 'Property 4', 'Property 5', 'Property 6', 'Property 1'] 
fig.add_trace(go.Scatterpolar(r=[1]*7, theta=theta, fill=None, name='T-Score'))
res= [1.5, 1.5, 1.5, 0.5, 0.5, 0.5, 1.5]
fig.add_trace(go.Scatterpolar(r=res, theta=theta, fill='tonext',
                              line_color=color_s, fillcolor=color_s, name='Data'))

```

![twopolar_charts](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/3/9/3961f98ed966514fa6bf82cb6c5297a4ed5fd7e5.png)

then I can help you. Does radius =-0.5 have a meaning in the context of your data?  
Please explain what your points represent, to understand why you considered such odd polar coordinates, with center at -1, and radius 0!!! From mathematical point of view this is a non-sense and no computations can be performed. The example posted on stackoverflow is a numerical one, and the comparisons can be performed, but not in your case, where theta is a categorical variable, and radii are some 0, other negative or positive.
