相关疑难解决方法(0)

使用PyPlot绘制平滑线

我有以下简单的脚本绘制图表:

import matplotlib.pyplot as plt
import numpy as np

T = np.array([6, 7, 8, 9, 10, 11, 12])
power = np.array([1.53E+03, 5.92E+02, 2.04E+02, 7.24E+01, 2.72E+01, 1.10E+01, 4.70E+00])

plt.plot(T,power)
plt.show()
Run Code Online (Sandbox Code Playgroud)

就像现在一样,这条直线从一点到另一点直线看起来不错,但在我看来可能更好.我想要的是平滑点之间的界限.在Gnuplot,我会用smooth cplines.

在PyPlot中有一种简单的方法吗?我找到了一些教程,但它们看起来都相当复杂.

python plot matplotlib curvesmoothing

104
推荐指数
6
解决办法
15万
查看次数

使用matplotlib生成平滑的线图

以下是使用matplotlib生成绘图的python脚本.

#!/usr/bin/python

import matplotlib.pyplot as plt
import time
import numpy as np
from scipy.interpolate import spline

# Local variables
x = []
y = []

# Open the data file for reading lines
datafile = open('testdata1.txt', 'r')
sepfile = datafile.read().split('\n')
datafile.close()

# Create a canvas to place the subgraphs
canvas = plt.figure()
rect = canvas.patch
rect.set_facecolor('white')

# Iterate through the lines and parse them
for datapair in sepfile:
    if datapair:
        xypair = datapair.split(' ')
        x.append(int(xypair[1]))
        y.append(int(xypair[3]))

# Define the matrix …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

13
推荐指数
1
解决办法
5万
查看次数

标签 统计

matplotlib ×2

python ×2

curvesmoothing ×1

plot ×1