Home > Net >  Converting Matplotlib axis to log only updates labels and not step spacing
Converting Matplotlib axis to log only updates labels and not step spacing

Time:01-17

I am trying to scale the space on the vertical axis here so it is spaced logarithmically.

After searching the internet the proposed solution was

ax.set_zscale('log')

After trying that you can see the result below that only the labels where changed and not the actual spacings.

Before

Before

After

Chart

CodePudding user response:

Unfortunately, the documentation for set_zscale says:

The axis scale type to apply. 3D axes currently only support linear scales; other scales yield nonsensical results.

So, the other option is just to take the log of your input z-axis values and label the axis accordingly, e.g.,

import numpy as np

ax.scatter(x, y, np.log10(z))

ax.set_zlabel("log10(GDP Per Capita)")
  • Related