Skip to content

Double zeros on axis when using tozero rangemode #7458

Open
@jl22411L

Description

@jl22411L

When the origin of the plot corresponds to the same value on the x and y axis it will display the value twice instead of once. (example is provided below, the zero value on both axis is shown twice). Using anchor and zeroline positioning etc doesn't remove this from the plot.

Image

The code I used is shown below. The input figure has the data loaded onto the figure in a 3D scatter plot:

def classical(figure: go.Figure,
              plotTitle: str = '',
              xAxisTitle: str = '',
              yAxisTitle: str = '',
              legendTitle: str = '',
              size_cm: tuple = (8, 8),
              equalAspectRatio: bool = False) -> go.Figure:
  '''
  @brief    Function which applies a classical look to figure in formatting.

  @Args     figure (in)
            This is the inputted figure which will be formatted. This figure
            should have the data in the graph along with the name of different
            datas in the legends if a multi scatter plot is to be creaated.

  @Return   figure (out)
            Figure with the classical formatting applied to the plot.
  '''

  layout = go.Layout(
    width=int(size_cm[0] * 300 / 2.54),
    height=int(size_cm[1] * 300 / 2.54),

    title={
        'text': f'<b>{plotTitle}</b>',
        'font': {'size': 36},
        'font_family': 'Times New Roman',
        'x': 0.5,
        'xanchor': 'center'
    },

    xaxis={
        'title': {
          'text': f'{xAxisTitle}',
          'font': {'size': 32},
          'font_family': "Times New Roman"},
        'rangemode': 'tozero'
    },

    yaxis={
        'title': {
          'text': f'{yAxisTitle}',
          'font': {'size': 32},
          'font_family': "Times New Roman"},
        'rangemode': 'tozero',
        'zeroline': True
    },

    legend={'title': f'{legendTitle}',
            'y': 0.5,
            'yanchor': 'middle'},
  )

  figure = figure.update_layout(layout)

  # If requested, set aspect ratio to be equal for both axis
  if equalAspectRatio is True:
    figure.update_yaxes(scaleanchor='x')

  return figure

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions