Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Font properties not applied for log scale with negative exponent #15845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Svdvoort opened this issue Dec 6, 2019 · 3 comments
Closed

Font properties not applied for log scale with negative exponent #15845

Svdvoort opened this issue Dec 6, 2019 · 3 comments

Comments

@Svdvoort
Copy link

Svdvoort commented Dec 6, 2019

Bug report

Bug summary

Font options do no apply correctly when using a logarithmic scale with numbers smaller than 1 (i.e. negative exponents). This issue seems related for positive exponents.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

tick_size = 25

x = np.arange(1, 500)
y_small = np.power(x, -0.1)
y_large = np.power(x, 2)

plt.figure()
ax1 = plt.axes()
ax1.plot(x, y_large)
ax1.set_yscale("log")
ax1.tick_params(labelsize=tick_size)

plt.figure()
ax2 = plt.axes()
ax2.plot(x, y_small)
ax2.set_yscale("log")
ax2.tick_params(labelsize=tick_size)

plt.show()

Actual outcome

For log values with negative exponents, the font size is not correctly set:

Small_log_values

Expected outcome
Similar behavior as in the situation when working with a log scale with positive exponents:

Large_log_values

Matplotlib version

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 3.1.2
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6.9
  • Jupyter version (if applicable): N/A
  • Other libraries: Numpy version 1.17.0

All packages installed through pip in a virtual environment.

@jklymak
Copy link
Member

jklymak commented Dec 6, 2019

What’s happening is those are minor ticks.

@Svdvoort
Copy link
Author

Svdvoort commented Dec 6, 2019

Indeed, setting:

ax2.tick_params(labelsize=tick_size, which='minor')

solves the issue, thanks for the suggestion.

However, this behavior is perhaps not the most intuitive, as (especially when using only values < 1), there is no clear reason why they suddenly turn into minor ticks. But perhaps this is expected behavior.

@jklymak
Copy link
Member

jklymak commented Dec 6, 2019

Its a workaround the fact that the major locator only finds factors of 10. I'm not actually in favour of this way of handling the problem, but thats what we have, and it'd be a break to make it work differently.

@Svdvoort Svdvoort closed this as completed Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants