Setting Layout in Groupby Scatter

Hi There,

I’m trying to set the labels for the axes in the code below. I was just trying to start with basic labels, and then was going to adjust the tickvals on the x-axis with #ticktext=[‘C’, ‘D’, …]

However, I keep getting this error:
ValueError: Invalid property specified for object of type plotly.graph_objs.Scatter: ‘transforms’

If you have any advice here, I’d appreciate it!

x = df_transform.key
y = df_transform.tempo

data = [dict(
type = ‘scatter’,
x = x,
y = y,
mode = ‘markers’,
transforms = [dict(
type = ‘groupby’,
groups = key,
styles = [
dict(target = 0.0, value = dict(marker = dict(color = ‘rgb(244, 92, 66)’))),
dict(target = 1.0, value = dict(marker = dict(color = ‘rgb(244, 178, 65)’))),
dict(target = 2.0, value = dict(marker = dict(color = ‘rgb(244, 244, 65)’))),
dict(target = 3.0, value = dict(marker = dict(color = ‘rgb(133, 244, 65)’))),
dict(target = 4.0, value = dict(marker = dict(color = ‘rgb(17, 104, 46)’))),
dict(target = 5.0, value = dict(marker = dict(color = ‘rgb(15, 226, 202)’))),
dict(target = 6.0, value = dict(marker = dict(color = ‘rgb(14, 81, 226)’))),
dict(target = 7.0, value = dict(marker = dict(color = ‘rgb(138, 100, 209)’))),
dict(target = 8.0, value = dict(marker = dict(color = ‘rgb(219, 15, 226)’))),
dict(target = 9.0, value = dict(marker = dict(color = ‘rgb(155, 10, 68)’))),
dict(target = 10.0, value = dict(marker = dict(color = ‘rgb(130, 126, 127)’))),
dict(target = 11.0, value = dict(marker = dict(color = ‘rgb(117, 42, 42)’)))
]
)]
)]
layout = go.Layout(
xaxis=dict(
title=‘AXIS TITLE’,
titlefont=dict(
family=‘Arial, sans-serif’,
size=18,
color=‘lightgrey’
),
showticklabels=True,
tickangle=45,
tickfont=dict(
family=‘Old Standard TT, serif’,
size=14,
color=‘black’
),
exponentformat=‘e’,
showexponent=‘all’
),
yaxis=dict(
title=‘AXIS TITLE’,
titlefont=dict(
family=‘Arial, sans-serif’,
size=18,
color=‘lightgrey’
),
showticklabels=True,
tickangle=45,
tickfont=dict(
family=‘Old Standard TT, serif’,
size=14,
color=‘black’
),
exponentformat=‘e’,
showexponent=‘all’
)
)
fig = go.Figure(data=data, layout=layout)
iplot(fig, filename=‘axes-labels’)

Hi @t.shaefrench,

The transforms mechanism in Plotly.js is very well supported in plotly.py. When working in Python I generally recommend using pandas for this functionality. Here’s an example I posted just this morning of using
a pandas groupby to construct a collection of traces from a DataFrame (Similar to seaborn’s hue function in plotly)

If you want to stick with transform, then don’t use the objects in the graph_objs package. Instead, represent your figure with plain dicts and lists. Then pass the figure dict into iplot and set the validate argument to False: iplot(fig, validate=False)

Hope that helps!

If you’d like some more help with your particular example, please include some sample data for df_transform and repost the code using “Fenced code blocks” (This way the code formattting won’t get messed up by the markdown renderer).

Thanks!

-Jon