# How to change size of point in px.strip plot

**URL:** <https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [December 3, 2022, 9:27pm UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506 "2022-12-03T21:27:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yogi\_dhiman](https://avatars.discourse-cdn.com/v4/letter/y/f04885/32.png) [@yogi\_dhiman](https://community.plotly.com/u/yogi_dhiman)\
**Post date:** [December 3, 2022, 9:27pm UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506/1 "2022-12-03T21:27:44Z")

</div>

How can I change the point size in px.strip plot ?

[https://plotly.com/python-api-reference/generated/plotly.express.strip.html](https://plotly.com/python-api-reference/generated/plotly.express.strip.html)

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [December 3, 2022, 10:57pm UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506/2 "2022-12-03T22:57:13Z")

</div>

Hi @yogi_dhiman, same approach as in the scatter plot 🙂

`fig.update_traces({'marker':{'size': your_desired_size}})`

Full example:

```python
import plotly.express as px

df = px.data.tips()
fig = px.strip(df, x='total_bill', y='day')
fig.update_traces({'marker':{'size': 50, 'color': 'pink'}})

```

creates:

 ![newplot(22)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/3/2/3254bcdc05b919b286ee4d50fd21b7c5a66ed6d4.png)

---

<div class="post-metadata">

**Author:** ![yogi\_dhiman](https://avatars.discourse-cdn.com/v4/letter/y/f04885/32.png) [@yogi\_dhiman](https://community.plotly.com/u/yogi_dhiman)\
**Post date:** [December 5, 2022, 5:05pm UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506/3 "2022-12-05T17:05:20Z")

</div>

> [@AIMPED](#):
>
> `fig.update_traces({'marker':{'size': 50, 'color': 'pink'}})`

what if want to give size based on some variable  
will following work

fig.update\_traces({‘marker’:{‘size’: df[‘size’], ‘color’: df['color]}})

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [December 6, 2022, 11:52am UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506/4 "2022-12-06T11:52:36Z")

</div>

Hi, you can change the marker size and color for each trace:

> [@Scatter color not match with its legend](https://community.plotly.com/t/scatter-color-not-match-with-its-legend/70532/6):
>
> Hi, you can do so using the selector argument of figure.update\_traces() fig.update\_traces({'opacity': 0.5}, selector={'name': 'won'}) fig.update\_traces({'opacity': 1.0}, selector={'name': 'lost'}) You could even change the size or marker color the same way: fig.update\_traces({'opacity': 0.5}, selector={'name': 'won'}) fig.update\_traces({'opacity': 1.0, 'marker':{'color':'blue','size':10}}, selector={'name': 'lost'}) [newplot (25)] mrep traces

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [December 6, 2022, 10:40pm UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506/5 "2022-12-06T22:40:10Z")

</div>

Hi @yogi_dhiman,

I admit, I got a bit carried away by your question and came up with a scatter strip plot 😂

What gets lost in this process, is the separation of the data points for a given y-coordinate (in this case the weekday) which is created by `px.strip`

```python
import plotly.express as px
import plotly.graph_objects as go

# create data
df = px.data.tips()

# calculate relative tip
df['rel_tip'] = df.tip / df.total_bill *100
df.rel_tip = df.rel_tip.apply(round,0)

# set the marker size
# all relative tips above 25% --> 30
# all relative tips above 20% to 25% --> 20
# rest --> 10
size=[]
for tip, gender in zip(df.rel_tip, df.sex):
    if tip>25:
        size.append(30)
    elif 20<tip<=25:
        size.append(20)
    else:
        size.append(10)

# set marker color, female=gold, male=crimson
color=[['crimson', 'gold'][gender == 'Female'] for gender in df.sex]

# create plotly.graph_objects Figure() and add trace
figure = go.Figure()
figure.add_scatter(
    x=df.total_bill,
    y=df.day,
    mode='markers',
    marker={'size': size, 'color': color}
    )
figure.update_layout(template='plotly_dark')
figure.show()

```

creates:

 ![newplot (26)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/f/6/f6da8a9ec93e32b4198468e40b2d4cdb215994fc.png)

---

<div class="post-metadata">

**Author:** ![yogi\_dhiman](https://avatars.discourse-cdn.com/v4/letter/y/f04885/32.png) [@yogi\_dhiman](https://community.plotly.com/u/yogi_dhiman)\
**Post date:** [December 15, 2022, 6:47pm UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506/6 "2022-12-15T18:47:18Z")

</div>

AIMPED i am looking for the point size based on variable value in strip plot itself ( your assumption was correct )  
Can we do it ?

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [December 16, 2022, 7:58am UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506/7 "2022-12-16T07:58:33Z")

</div>

Hey @yogi_dhiman, I did not figure out how to do it. Actually I do not think it’s possible. The marker + color argument does not accept iterables. You can see this by switching the chart type:

```python
import plotly.express as px
import numpy as np

# data
df = px.data.tips()

# figure
px_fig = px.strip(df, x='total_bill', y='day')
#px_fig = px.scatter(df, x='total_bill', y='day')

# update marker size
marker_size = np.random.randint(1, 30, df.shape[0])
px_fig.update_traces({'marker':{'size':marker_size}})

```

---

<div class="post-metadata">

**Author:** ![edmoman](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/edmoman/32/20693_2.png) [@edmoman](https://community.plotly.com/u/edmoman)\
**Post date:** [May 22, 2023, 12:14pm UTC](https://community.plotly.com/t/how-to-change-size-of-point-in-px-strip-plot/70506/8 "2023-05-22T12:14:49Z")

</div>

This is a big limitation of the strip plot, in my opinion. As I have too many points to be displayed, I am clustering them, it would be great to have an indication of the size of each cluster. Colour is not an option in this case, as I have already coloured the markers by using a different property.
