简体   繁体   English

Matplotlib 的符号对数(又名对称对数)比例的起源是什么?

[英]What is the origin of Matplotlib's symlog (a.k.a. symmetrical log) scale?

This is not really a programming question.这不是一个真正的编程问题。 Rather a historical one...而是一个历史...


I am wondering about Matplotlib's symlog or "symmetrical log" scale:我想知道 Matplotlib 的符号对数或“对称对数”比例:

  • Is it a Matplotlib invention?它是 Matplotlib 的发明吗?
  • Has anyone seen a similar feature in another plotting tool?有没有人在另一个绘图工具中看到过类似的功能? A math text book?数学课本? Elsewhere?在别处?

For completeness, and as the documentation is a little bit on the short side:为了完整性,并且由于文档有点短:

In essence, symlog gives a linear scale below a certain threshold and a log scale above.本质上, symlog给出了低于某个阈值的线性标度和高于某个阈值的对数标度。 This allows plotting a wide range of numbers (as does a log scale), including negative number and zero (which is not possible with a conventional log scale).这允许绘制范围广泛的数字(如对数刻度),包括负数和零(传统的对数刻度不可能)。

There are some examples here and here . 这里这里有一些例子。


As suggested by @Paul, I went ahead and asked the original author of the Matplotlib implementation.正如@保罗的建议,我继续问了原作者的Matplotlib实施。 He "didn't invent the concept" but "believe[s] it was implemented on a user request".他“没有发明这个概念”,但“相信它是根据用户请求实现的”。 He couldn't find a reference in the Matplotlib mailing list, though.但是,他在 Matplotlib 邮件列表中找不到参考。

Can anyone point to such a reference?任何人都可以指出这样的参考吗? It might be very insightful.它可能非常有见地。

While browsing the web for the same answer, I found this MatLab package that implements the same function.在浏览网页寻找相同的答案时,我发现了这个实现相同功能的 MatLab 包。

In its description, the following is reported:在其描述中,报告了以下内容:

SYMLOG applies a modified logarithm scale to the specified or current axes that handles negative values while maintaining continuity across zero. SYMLOG 将修改后的对数刻度应用于处理负值的指定或当前轴,同时保持跨零的连续性。 The transformation is defined in an article from the journal Measurement Science and Technology (Webber, 2012)测量科学与技术杂志 (Webber, 2012) 上的一篇文章定义了这种转换

I think it's reasonable to assume that is the original source of the scale.我认为假设这是规模的原始来源是合理的。

This is more of an extended comment.这更像是一个扩展评论。 To extend the logarithm continuously (or better, smoothly) over all the real numbers, it is natural to stop at a small positive value, shift, and reflect.为了在所有实数上连续(或更好地,平滑地)扩展对数,很自然地停止在一个小的正值、移动和反映。 That is, taking 1 to be small, consider the function log(x+1) for x nonnegative and -log(-x+1) for x nonpositive.也就是说,取1为小,考虑函数log(x+1)表示x非负和-log(-x+1)表示x非正。 I've compared this with the symlog scale below, using the demo example plots (without the linthreshy modification).我已经使用演示示例图(没有linthreshy修改)将其与下面的symlog尺度进行了linthreshy

在此处输入图片说明

It's not exactly it though, as is evident in the slightly steeper first and second row left-side plots.但这并不完全是这样,这在稍微陡峭的第一行和第二行左侧图中很明显。 This can be modified by moving the symmetry from x=1 and x=-1 of the logarithm closer to zero, such as x=.1 and x=-.1 .这可以通过将对称性从对数的x=1x=-1移近零来修改,例如x=.1x=-.1 Also the region [-linthresh, linthresh] is linear, which is not the case in the right-side plots.此外,区域[-linthresh, linthresh]是线性的,右侧图中的情况并非如此。 Here is a function that produces this described approximation of matplotlib 's symlog , along with some options to toy around with.这是一个函数,它生成matplotlibsymlog描述近似值,以及一些可供选择的选项。

from math import log

def symmetric_logarithm(arg,base=10,shift=1):
    if arg >= 0:
        return log(arg+shift,base)-log(shift,base)
    else:
        return -log(-arg+shift,base)+log(shift,base)

I was digging around trying to make this happen in plotly , which does not have a symlog type scale ( issue is open ), by looking for the function that is used to make it.我试图通过寻找用于制作它的函数来尝试在plotly实现这一点,它没有symlog类型比例(问题是开放的)。

1) You would have to ask mdboom , who appears to have authored the relevant class (according to git blame), which is 1)您必须询问mdboom ,他似乎创作了相关课程(根据 git blame ),这是

2) SymmetricalLogScale. 2) SymmetricalLogScale。

Matplotlib has a github, and has been under version control for some time, so these questions are easily checked by reading the source + git blame. Matplotlib 有一个github,并且已经有一段时间的版本控制,所以这些问题通过阅读源码+ git blame 很容易检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM