X Tutup
Skip to content

Possible division by zero in new get_tick_space() methods; is rotation ignored? #6385

@efiring

Description

@efiring

The potential problems are in XAxis.get_tick_space() and YAxis.get_tick_space(). Here is the latter:

    def get_tick_space(self):
        ends = self.axes.transAxes.transform([[0, 0], [0, 1]])
        length = ((ends[1][1] - ends[0][1]) / self.axes.figure.dpi) * 72.0
        tick = self._get_tick(True)
        # Having a spacing of at least 2 just looks good.
        size = tick.label1.get_size() * 2.0
        size *= np.cos(np.deg2rad(tick.label1.get_rotation()))
        return np.floor(length / size)

Consider the last two lines. Presumably the rotation could be 90, in which case the last line would divide by zero. This raises the question of whether the prototype tick rotation ever actually gets set. Tick rotation is set by Figure.autofmt_xaxis, but the rotation angle set there does not end up in the prototype tick. Furthermore, what is the point of modifying the spacing based on the rotation, given that the spacing is calculated here from the prototype tick label font size, not from any expected actual label dimensions?

Metadata

Metadata

Assignees

Labels

Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    X Tutup