python - How to plot tick values in-place -


the following produces plot in y ticks -1, -0.5, 0, 0.5, 1 , scaling plotted elsewhere, how force matplotlib plot tics in-place -1e-9, -0.5-e9... don't have search other parts of plot potential corrections tick values?

import matplotlib.pyplot plot plot.plot([0, 1e-9, 0, -1e-9]) plot.show() 

google led me plot.ticklabel_format(useoffset = false) unfortunately doesn't have usescaling parameter.

one way y-axis tick values, format them like, , add them plot y-axis tick labels.

import matplotlib.pyplot plt plt.plot([0, 1e-9, 0, -1e-9])  # pull out values y-axis ticks yticks = plt.gca().get_yticks()  # format new labels new_yticklabels = ['{:0=4.2f}e-9'.format(tick/1e-9) tick in yticks]  # set new labels plt.gca().set_yticklabels(new_yticklabels)  plt.show() 

output

this may not best way, works. there way using ticker formatters such funcformatter.

this answer helpful getting scientific notation formatting correct.


Comments

Popular posts from this blog

Unlimited choices in BASH case statement -

Redirect to a HTTPS version using .htaccess -

javascript - jQuery: Add class depending on URL in the best way -