Customizing the x & y axes of a 3D Surface plot


I am making a 3d surface plot from the values stored in a Pandas DataFrame (called z_data). Ideally, in the plot, the x-axis ticks would reflect z_data’s 40 index values ([1.82, 2.33, 2.83, … , 20.83]) and the y-axis ticks would be z_data’s 14 column values ([0.5, 1, 1.5, …, 7]).

I can technically achieve this using the ‘ticktext’ & ‘tickvals’ parameters of the ‘scene’ attribute in the following way:

    layout = go.Layout(
                scene = dict(
                    xaxis = dict(
                        title = 'Energy Storage Duration (Hours)',
                        nticks = 5,
                       #tickmode = 'array',
                        ticktext = z_data.columns,
                        tickvals= list(range(0,z_data.shape[1]))),
                        #ticksuffix=' Hours'),
                    yaxis = dict(
                        title = 'Combined Total Peak Power (MVA)',
                        nticks = 5,
                        #tickmode = 'array',
                        ticktext = z_data.index,
                        tickvals= list(range(0,z_data.shape[0]))),
                    zaxis = dict(
                        title = 'Years of Deferral'),
                title='Years Deferred for a Total DG Power / Storage Energy Capacity Combination',

The problem is, this shows every single axis value that i’ve specified. (see the image below)

The x-axis here is fine, but the y-axis is unreadable.

Is there a way to specify the number of axis ticks to use in my situation? For the ‘nticks’ parameter to work I have to set tickmode = ‘auto’ which forces the x & y-axis values to be the relative positions of each z-value within the dataframe, which I don’t want. I would like to use my custom x & y axis values with the option to show only a few of the labels on the axes.

Thanks in advance!

1 Like

Hi @jhthompson12,

I don’t think it’s possible to combine tickvals/ticktext with the auto tick mode. But it’s an interesting idea. Feel free to open an issue at to discuss.


Thanks for the response! I just submitted one here. Please let me know if you need any other information.