python-novice-gapminder icon indicating copy to clipboard operation
python-novice-gapminder copied to clipboard

Use of EngFormatter in plots for readability

Open jonititan opened this issue 6 years ago • 2 comments

Plotting within python using pyplot includes some very powerful functions useful to scientists and engineers. One in particular which I have found excellent for improving the readability of my plots and also for formatting of data into strings and messages is the EngFormatter function. It is a tick formatter in pyplot and has the obvious benefits shown for improving intelligibility of plots. It can be used outside of the plot figure environment to format numbers for strings in the following way.

from matplotlib.ticker import EngFormatter formatter_freq = EngFormatter(unit='Hz') print("Frequency is {}".format(formatter_freq(1000000)))

result is "Frequency is 1 MHz"

If this would be a welcome change I can work in an update to submit. I think it would fit best in chapter 9.

jonititan avatar May 14 '19 13:05 jonititan

I have had feedback from other instructors that this change and indeed the use of .format() on strings is too high level for this lesson. I can certainly see that argument but the more I read this lesson with the other Python programming lesson the more I see there is a high degree of overlap with python-novice-inflammation

jonititan avatar May 31 '19 07:05 jonititan

I think format strings are great, and definitely something to point learners at as a "would you like to learn more...".

Thoughts from other maintainers?

alee avatar Aug 22 '19 07:08 alee