简体   繁体   English

plt.plot(x[0:-1],y/y[0]) 是什么意思?

[英]What's meaning of plt.plot(x[0:-1],y/y[0])?

I am plotting an exponential distribution using the information provided by the tutor.我正在使用导师提供的信息绘制指数分布。

plt.plot(x[:-1],y/y[0])
plt.plot(tvals,pvals)
plt.show()

But, I do not know what's meaning of x[:-1] and y/y[0]?但是,我不知道 x[:-1] 和 y/y[0] 是什么意思?

x[:-1] means all the elements except the last one x[:-1] 表示除最后一个之外的所有元素

y/y[0] is simply dividing the array y by the first value ie y[0] of the array. y/y[0] 只是将数组 y 除以数组的第一个值,即 y[0]。

Code Example代码示例

import numpy as np
import matplotlib.pyplot as plt

x = np.array([1, 3, 5, 7])
y = np.array([2, 4, 6])

a = x[:-1]  # [1, 3, 5]
b = y/y[0]  # [1, 2, 3]

plt.plot(a, b)

Output输出

输出

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

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