Skip to content

bar_chart ignores the zorder option (bars always drawn under gridlines) #41207

@fernandodemorais-jf

Description

@fernandodemorais-jf

Steps To Reproduce

  1. Run the following minimal example in SageMath:
P = bar_chart([1, 2, 3],
              rgbcolor='blue',
              zorder=10,        # Should place bars on top
              gridlines=True,
              gridlinesstyle={'color': 'gray', 'lw': 1, 'zorder': 0}) # Grid behind

P.show()
  1. Observe the resulting plot;
  2. Notice that the gridlines appear above the bars, despite zorder=10.

Expected Behavior

  • Bars should be drawn above the gridlines when the user provides a larger zorder, such as zorder=10.
  • The zorder option should control drawing order, consistent with Matplotlib and other Sage graphics primitives.

Actual Behavior

  • The zorder option is ignored;
  • Users cannot control the drawing order of bars using the zorder parameter.

Additional Information

Suggested fix

Modify the _render_on_subplot method to forward the zorder option:

subplot.bar(
    ind,
    datalist,
    color=color,
    width=width,
    label=options['legend_label'],
    zorder=options.get('zorder', None)   # <<< FIX
)

Environment

  • OS: Arch Linux x86_64
  • Sage Version: 10.5

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions