Skip to content Skip to sidebar Skip to footer

Plot Axis In Python With Log Scale For Negative Exponents Of 10

I need to plot my y-axis using a logarithmic scale. yscale('log') or yscale('symlog') only scales the axis for positive powers of 10, i.e. 10^1, 10^2, 10^3, etc. My data are mainly

Solution 1:

We use .set_yscale('log') on the axes simply. Here a simple example:

# Create sample data
x = np.arange(0, 20)
y = np.linspace(1e-9, 1e-1, 20)

plt.plot(x, y, 'o--')
plt.gca().set_yscale('log')

example_log_y

Post a Comment for "Plot Axis In Python With Log Scale For Negative Exponents Of 10"