Matplotlib so log axis only has minor tick mark labels at specified points. Also change size of tick labels in colorbar

后端 未结 2 1253
再見小時候
再見小時候 2020-12-02 15:51

I am trying to create a plot but I just want the ticklabels to show as shown where the log scale is shown as above. I only want the minor ticklabel for 50, 500 and 2000 to s

2条回答
  •  星月不相逢
    2020-12-02 16:51

    Based on the answer from @Paul I created the following function:

    def get_formatter_function(allowed_values, datatype='float'):
        """returns a function, which only allows allowed_values as axis tick labels"""
        def hide_others(value, pos):
            if value in allowed_values:
                if datatype == 'float':
                    return value
                elif datatype == 'int':
                    return int(value)
            return ''
        return hide_others
    

    Which is a bit more flexible.

提交回复
热议问题