go.Carpet tickvals and ticktext does not work

Hello,

I’ve scoured the internet and asked several AIs but I can’t get this very simple example to work. I’m hoping I’m missing something obvious. The example below works if you comment out the aaxis and baxis dictionaries, if not the page shows up white, and then you can find this error by inspecting the html:

(index):12 Uncaught TypeError: Cannot read properties of undefined (reading '0')
    at Z.tickText ((index):12:512759)
    at t.exports ((index):12:933902)
    at t.exports [as calc] ((index):12:929573)
    at b ((index):12:786972)
    at w.doCalcdata ((index):12:787096)
    at e._doPlot ((index):12:446319)
    at e.newPlot ((index):12:442396)
    at (index):12:4558090

Example:

import plotly.graph_objects as go

fig = go.Figure()

# Sample data
a_values = [4, 4, 4, 4.5, 4.5, 4.5, 5, 5, 5, 6, 6, 6]
b_values = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
y_values = [2, 3.5, 4, 3, 4.5, 5, 5.5, 6.5, 7.5, 8, 8.5, 10]

fig.add_trace(go.Carpet(
    a=a_values,
    b=b_values,
    y=y_values,
    aaxis=dict(
        tickvals=[4, 4.5, 5, 6],
        ticktext=['tacos', 'are', 'very', 'good'],
        tickmode='array'
    ),
    baxis=dict(
        tickvals=[1, 2, 3],
        ticktext=['I', 'love', 'plotly'],
        tickmode='array'
    )
))

fig.show()

Thanks!

I have never created a graph of this type, but I have tried based on the example in the reference. It looks like the string endings and prefixes need to be specified for the A and B axes at the same time.

import plotly.graph_objects as go

fig = go.Figure()

# Sample data
a_values = [4, 4, 4, 4.5, 4.5, 4.5, 5, 5, 5, 6, 6, 6]
b_values = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
y_values = [2, 3.5, 4, 3, 4.5, 5, 5.5, 6.5, 7.5, 8, 8.5, 10]

fig.add_trace(go.Carpet(
    a=a_values,
    b=b_values,
    y=y_values,
    aaxis = dict(
        # tickprefix = 'a = ',
        ticksuffix = 'm',
        smoothing = 1,
        #minorgridcount = 9,
    ),
    baxis = dict(
        # tickprefix = 'b = ',
        ticksuffix = '',
        smoothing = 1,
        #minorgridcount = 9,
    )
))

fig.show()

Thanks for your reply. I’m not looking to just add suffixes or prefixes. Rather I want to use tickvals / ticktext to specify the ticks I want to show.

I’ll update the example to avoid confusion.