Adjust plotly axes limits and axes title positions on a ternary scatter plot
Asked Answered
G

0

8

I am trying to plot data from three columns in a dataframe in a scatter_ternary diagram with contoured datapoints.

The columns in the dataframe are Power (W), Speed (mm/s), and Hatch (mm), and I am using another column in the dataframe (Energy Density (J/mm^3)) to vary the size of each datapoint and another column Relative Density (%) to apply the contour.

The data is min-max normalized from 0-1 since the scale of the column values vary by a few orders of magnitude. I have written the code below:

fig = px.scatter_ternary(df_all, 'Power (W)', 'Speed (mm/s)', 'Hatch (mm)',
                         hover_name="Build", symbol="Build", size = "Energy Density (J/mm^3)", 
                         color="Relative density (%)",
                         title='Process Window', size_max=15, width=875, height=700,
                         symbol_sequence = [0,3,5,14,2,26])

# move colorbar
fig.update_layout(coloraxis_colorbar=dict(yanchor="top", y=1.05, x=1, 
                  ticks="outside", ticksuffix="%"))

# move legend
fig.update_layout(legend=dict(yanchor="top", y=1.025, x=0.775))

fig.update_layout({
        'ternary':
            {
            'sum':1,
            'aaxis':{'title': 'Min-Max Normalized Laser Power<br>', 'min': 0, 
                     'linewidth':2, 'ticks':'outside',
                     'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]},
            'baxis':{'title': '<br>Min-Max Normalized Laser Scan Velocity', 'min': 0, 
                     'linewidth':2, 'ticks':'outside',
                     'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]},
            'caxis':{'title': '<br>Min-Max Normalized Hatch Spacing', 'min': 0, 
                     'linewidth':2, 'ticks':'outside',
                     'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]}}})

fig.show()

Which produces this figure:

How would I change or scale the axes limits so that the datapoints in the bottom right corner are more visible? Also, how would I move each axis title to the center of each axis instead of the pole?

Groff answered 16/6, 2020 at 18:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.