Python Matplotlib.pyplot.loglog()用法及代码示例

转自:https://vimsky.com/examples/usage/matplotlib-pyplot-loglog-function-in-python.html

Matplotlib 是一个综合库,用于在 python 中创建交互式,静态和动画可视化。使用wxPython,SciPy,Tkinter 或 SciPy 之类的 general-purpose GUI 工具包,它提供了一个面向对象的 API,用于将图嵌入到应用程序中。 Matplotlib.pyplot 是使 Matplotlib 像 MATLAB 一样工作的函数集合。

在这里,我们将探索 Matplotlib.pyplot 的 loglog() 函数。它用于在 x 和 y 轴上绘制对数刻度

用法:

loglog(X,Y)

其中,

X 和 Y 分别指 x 和 y 坐标。

使用的其他函数是 linespace()。它在指定的间隔内返回均等的数字。

用法:

np.linspace(start, stop, num, endpoint, retstep, dtype, axis)

其中,

  • Start :您要显示线条的位置的序列起始值,或者我们可以说线条的起点
  • Stop:除非‘endpoint’设置为False,否则它是行停止处序列的结束值。
  • Num:要生成的样本数。必须为非负数。默认情况下为50。
  • Endpoint:与停止相同。如果为True,则stop是最后一个样本,否则stop将从序列中排除。
  • Retstep:如果为True,则返回(‘samples’, ‘step’),其中 step 是样本之间的间隔。
  • Dtype:输出数组的类型。
  • Axis :结果中存储样本的轴,仅当开始或停止为array-like时才相关

例:没有 loglog()

# importing requried modules 
import matplotlib.pyplot as plt 
import numpy as np   
  
# inputs to plot using loglog plot 
x_input = np.linspace(0, 10, 50000)   
y_input = x_input**8
  
# plotting the value of x_input and y_input using plot function 
plt.plot(x_input, y_input)

输出:
在这里插入图片描述
例:与 loglog()

Python3

# importing requried modules 
import matplotlib.pyplot as plt 
import numpy as np   
  
# inputs to plot using loglog plot 
x_input = np.linspace(0, 10, 50000)   
y_input = x_input**8
  
# plotting the value of x_input and y_input using loglog plot 
plt.loglog(x_input, y_input)

输出:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值