Python uses matplotlib,numpy,scipy to make a scatter smoothing curve __python

Source: Internet
Author: User

First, give a curve without smooth.

Import Matplotlib.pyplot as Plt
import numpy as np

T = Np.array ([6, 7, 8, 9, ten, One,]) 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 ()

The output curve is shown below

Using the SCIPY library can be used to smooth curves

The code is as follows

Import Matplotlib.pyplot as Plt
import NumPy as NP
from scipy.interpolate import spline

T = Np.array ([6, 7, 8, 9, one, one]) power
= Np.array ([1.53E+03, 5.92E+02, 2.04E+02, 7.24E+01, 2.72E+01, 1.10E+01, 4.70E+00])
xnew = n P.linspace (T.min (), T.max (), #300 represents number of points to make between T.min and T.max

power_smooth = Splin E (t,power,xnew)

plt.plot (Xnew,power_smooth)
plt.show ()

The output picture is


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.