Skip to content Skip to sidebar Skip to footer

Python- Compress Lower End Of Y-axis In Contourf Plot

The issue I have a contourf plot I made with a pandas dataframe that plots some 2-dimensional value with time on the x-axis and vertical pressure level on the y-axis. The field, ti

Solution 1:

You can use a custom scale transformation with ax.set_yscale('function', functions=(forward, inverse)) as you suggested. From the documentation:

forward and inverse are callables that return the scale transform and its inverse.

In this case, define in forward() the function you want, such as the inverse of the log function, or a more custom one for your need. Call this function before your y-axis customization.

defforward(x):
    return2**x

definverse(x):
    return np.log2(x)

ax.set_yscale('function', functions=(forward,inverse))

Post a Comment for "Python- Compress Lower End Of Y-axis In Contourf Plot"