6

I want to change the fontsize of the exponent as marked on the picture pic I cannot use the matplotlib.rc('font', **font) method since I have different plots that need different font sizes so I change every element individually. I can however not find the font properties of the exponent.

6
  • Why don't you get rid of the exponent in the first place by dividing the data by 1e12 and noting that on the label? Commented Mar 22, 2013 at 10:30
  • Do you change the fontsize of the labels anywhere? The labels of the y-axes seem larger than those of the x-axis. You can perhaps use something like tick_params. Commented Mar 22, 2013 at 12:56
  • @Robbert: yes I changed all the other fonts, just can't find out how to do it for the exponent. Commented Mar 22, 2013 at 13:06
  • @tiago: Maybe an option, but then I need to calculate the exponent that fit's best myself. Commented Mar 22, 2013 at 13:08
  • is the exponent an offsetText? If not, how is computed? Commented Mar 22, 2013 at 13:34

1 Answer 1

17

If the exponent is an offset computed by matplotlib you can do the following to change the font size of the exponent to 30

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(1,1.0001,100)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x)
t = ax.yaxis.get_offset_text()
t.set_size(30)
plt.show()
Sign up to request clarification or add additional context in comments.

2 Comments

For the record, this also works if the exponent is a multiplier too
if it is a colorbar, use something like this: t = cbar.ax.yaxis.get_offset_text() t.set_size(12)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.