栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

“ log”和“ symlog”有什么区别?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

“ log”和“ symlog”有什么区别?

我终于找到了一些时间来做一些实验,以了解它们之间的区别。这是我发现的:

  • log
    仅允许使用正值,并允许您选择如何处理负值(
    mask
    clip
    )。
  • symlog
    表示对数 对称 ,并允许正值和负值。
  • symlog
    允许在绘图内将范围设置为零左右,而不是对数,而是线性的。

我认为通过图形和示例,一切都将变得更加容易理解,因此让我们尝试一下:

import numpyfrom matplotlib import pyplot# Enable interactive modepyplot.ion()# Draw the grid linespyplot.grid(True)# Numbers from -50 to 50, with 0.1 as stepxdomain = numpy.arange(-50,50, 0.1)# Plots a simple linear function 'f(x) = x'pyplot.plot(xdomain, xdomain)# Plots 'sin(x)'pyplot.plot(xdomain, numpy.sin(xdomain))# 'linear' is the default mode, so this next line is redundant:pyplot.xscale('linear')

# How to treat negative values?# 'mask' will treat negative values as invalid# 'mask' is the default, so the next two lines are equivalentpyplot.xscale('log')pyplot.xscale('log', nonposx='mask')

# 'clip' will map all negative values a very small positive onepyplot.xscale('log', nonposx='clip')

# 'symlog' scaling, however, handles negative values nicelypyplot.xscale('symlog')

# And you can even set a linear range around zeropyplot.xscale('symlog', linthreshx=20)

为了完整起见,我使用以下代码保存每个图:

# Default dpi is 80pyplot.savefig('matplotlib_xscale_linear.png', dpi=50, bbox_inches='tight')

请记住,您可以使用以下方法更改图形大小:

fig = pyplot.gcf()fig.set_size_inches([4., 3.])# Default size: [8., 6.]

(如果您不知道我的回答我的问题,请阅读本)



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/646528.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号