ipywidgets 滑块的科学记数法
Scientific notation for ipywidgets slider
在ipywidgets
中,如何对较大的滑块值使用科学记数法?假设我有类似的东西:
FloatSlider(min=1e7, max=1e9, step=1e7)
滑块上的显示将全为零。我能以某种方式将其转换为科学记数法吗?
如果您阅读帮助,您会发现有一段内容是这样说的:
readout_format : str
default is '.2f', specifier for the format function used to represent
slider value for human consumption, modeled after Python 3's format
specification mini-language (PEP 3101).
所以:
FloatSlider(min=1e7, max=1e9, step=1e7, readout_format='.2e')
应该完成这项工作。
在ipywidgets
中,如何对较大的滑块值使用科学记数法?假设我有类似的东西:
FloatSlider(min=1e7, max=1e9, step=1e7)
滑块上的显示将全为零。我能以某种方式将其转换为科学记数法吗?
如果您阅读帮助,您会发现有一段内容是这样说的:
readout_format : str
default is '.2f', specifier for the format function used to represent
slider value for human consumption, modeled after Python 3's format
specification mini-language (PEP 3101).
所以:
FloatSlider(min=1e7, max=1e9, step=1e7, readout_format='.2e')
应该完成这项工作。