0

I've plotted the following graph: enter image description here

but I want the 1e-4 to be something like LaTex formatting, and to be along the side. I've tried using
ax.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter(useMathText=True, useOffset=True))

and
ax.yaxis.get_major_formatter().set_powerlimits((0,1)) separately, but they don't give the desired effect.

How can I make the y-axis look more "publishable"?

Jim421616
  • 1,434
  • 3
  • 22
  • 47
  • `...make the y-axis look more "publishable"` is pretty subjective. Have you spent some time looking through the matplotlib documentation, tutorial and gallery? Seems you need to figure out how to get the y axis to intersect the x axis where x = 0. – wwii Sep 28 '17 at 02:19
  • [Here](https://ga7g08.github.io/2015/07/22/Setting-nice-axes-labels-in-matplotlib/) is a blog post about this problem, with the solution to move the exponent into the y axis label. Here you could simply multiply all data values by 10^6, and have a y axis range from 0 to ~251 J/sr (I find 200 J/sr more intuitive than 2E-4 MJ/sr, but I don't know what commonly done in astronomy). – user8153 Sep 28 '17 at 05:33
  • This is also discussed at https://stackoverflow.com/questions/31517156/adjust-exponent-text-after-setting-scientific-limits-on-matplotlib-axis with @user8153's blog post link adapting the SO answer. However, these sources leave the multiplier at the top of the y axis. See my answer for another way. – Bennett Brown Sep 28 '17 at 06:00
  • As seen in [this answer](https://stackoverflow.com/a/43216810/4124317) your approach seems correct. If you experience problems, it would be good to provide the exact code in use (or use the example from the linked answer) and a lot more details about versions of libraries etc. – ImportanceOfBeingErnest Sep 28 '17 at 07:07
  • 1
    I now marked as duplicate of [this answer](https://stackoverflow.com/questions/45760763/how-to-move-the-y-axis-scale-factor-to-the-position-next-to-the-y-axis-label) which seems to be what you want. – ImportanceOfBeingErnest Sep 28 '17 at 07:19

1 Answers1

0

For a publication, I presume each graph is a one-time production rather than something that needs to be done programatically. In that case, you can assign strings to the tick labels by calling set_yticklabels(a_list_of_strings). See https://matplotlib.org/api/axes_api.html#ticks-and-tick-labels .

Bennett Brown
  • 5,234
  • 1
  • 27
  • 35