windrose icon indicating copy to clipboard operation
windrose copied to clipboard

Change 'inf' label in legend

Open sampr7 opened this issue 4 years ago • 4 comments

inf label in the legend is not appropriate on most of the occasions. Instead of that, a greater than (>) symbol can be added to the maximum value.

legend labels [0.0 : 2.0 ) [2.0 : 4.0 ) [4.0 : 6.0 ) [6.0 : inf )

from this to this [0.0 : 2.0 ) [2.0 : 4.0 ) [4.0 : 6.0 ) >6.0

sampr7 avatar Sep 17 '21 09:09 sampr7

Change https://github.com/python-windrose/windrose/blob/b602213d9d6250d9e6eebaa7ac992fe9b6ec1b7a/windrose/windrose.py#L215-L230

to

        def get_labels(decimal_places=1, units=None):
            _decimal_places = str(decimal_places)

            fmt = "[%." + _decimal_places + "f " + ": %0." + _decimal_places + "f"

            labels = np.copy(self._info["bins"])
            labels[-1] = np.nan
            last_dig = labels[-2]
            if locale.getlocale()[0] in ["fr_FR"]:
                fmt += "["
            else:
                fmt += ")"

            if units:
                fmt += ' ' + units

            labels = [fmt % (labels[i], labels[i + 1]) for i in range(len(labels) - 1)]
            print(labels)
            labels[-1] = '>'+str(last_dig)
            return labels

windrose2

sampr7 avatar Sep 17 '21 09:09 sampr7

I am having this issue as well. Is there a plan to introduce this fix for the windrose legend?

evanleeturner avatar Jul 25 '22 16:07 evanleeturner

@sampr7 your fix looks OK to me. Do you want to send a PR?

ocefpaf avatar Jul 26 '22 13:07 ocefpaf

@sampr7 your fix looks OK to me. Do you want to send a PR?

@ocefpaf Sure. Will do

sampr7 avatar Jul 26 '22 15:07 sampr7

Thanks @sampr7! We merged #185 and I'll prepare a new release soon.

ocefpaf avatar Sep 21 '22 14:09 ocefpaf