
上QQ阅读APP看书,第一时间看更新
Using units of measurement
Sometimes, we may have data using one unit of measurement but want to draw the plot using a different unit of measurement, or sometimes we may want to use different units of measurement on the x and y axis, say centimeters on the x axis and inches on the y axis. The same is true for degrees and radians when we are plotting angles. Matplotlib does not have these functions built in, but there is an extension utility, basic_units.py, available on GitHub, which enables these different units of measurement. This Python module currently supports only centimeters/inches and radians/degrees. For other units of measurement, such as kg/lb, km/miles, and so on, we will have to update this utility module.
basic_units.py is not a standard package to be installed like all other Python packages. It is a user-defined Python program that needs to be copied into your working directory. Then, in the main program, import the functions from this program similar to the way we import any other package or user-defined programs.