python - 如何阻止 plt.plot() 的输出在 Jupyter 笔记本中出现两次
问题描述
import numpy as np
import matplotlib.pyplot as plt
def myplot1(t,x):
fig1 = plt.figure()
_ = plt.plot(t,x)
return fig1
def myplot2(t,x):
fig2 = plt.figure()
_ = plt.plot(t,x)
return fig2
t = np.arange(0,6,0.01)
x = np.sin(t)
y = np.cos(t)
#calling the functions
myplot1(t,x)
myplot1(t,y)
正如上面提到的示例代码,我的目标是一个接一个地绘制两个图形。在函数定义中,我使用了 return 语句,因为如果需要我还想保存这些数字。我在这里面临的问题是每次我调用一个函数时,例如 myplot1(t,x) 都会出现两个数字。您能否就如何解决该问题提供一些见解?
解决方案
推荐阅读
- angular - 如何在初始化反应角度形式时根据另一个表单控件的值禁用表单控件?
- java - Spring data jpa like query 兼容 Oracle 和 Postgres
- google-sheets - 如何解决有关数据验证的谷歌电子表格上的这个无效错误
- webrtc - webrtc peerconnection状态的实现与标准不一致
- unix - unix 中使用的比较运算符“==”在成功时未运行所需的条件
- python - “十进制”类型的对象不是 JSON 可序列化的
- angular - Ngrx-Component / VSCode - 嵌入式模板上的任何指令都没有使用属性绑定ngrxLet
- c++ - C++ 应用程序由于未知原因而崩溃?
- json - 在 JOLT 中验证和转换数组对象
- android - Android中使用JSON数据但没有页码作为API参数的分页