Skip to content

Instantly share code, notes, and snippets.

@arshpreetsingh
Created December 12, 2016 00:12
Show Gist options
  • Select an option

  • Save arshpreetsingh/bb8448b758d6ef0dc69dbd211b3428ad to your computer and use it in GitHub Desktop.

Select an option

Save arshpreetsingh/bb8448b758d6ef0dc69dbd211b3428ad to your computer and use it in GitHub Desktop.
Matplotlib playing with interpolation
from scipy.interpolate import interp1d
x= [1,2,3,4]
y = [1,2,12,25]
#x2 = np.arange(4,20)
#x2=[4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
y21 = np.arange(0,9,100)
x2 = [4,4.5,4.8,5.5,6,9,10,11,12,13,14,15,18,18.5,19,19.5,21]
y2=[1,2,4,6,7,9,9,9,9,9,9,9,7,6,4,2,1]
#x = np.linspace(0, 10, num=11, endpoint=True)
#y = np.cos(-x**2/9.0)
print len(x2)
print type(x),"###",type(y)
f = interp1d(x2, y2)
f2 = interp1d(x2, y2, kind='cubic')
fig = plt.figure()
fig.suptitle('Resistor FSS Absorption Analysis', fontsize=12)
plt.xlabel('Freq(GHz)', fontsize=12)
plt.ylabel('Reflectivity(dB)', fontsize=12)
#xnew = np.linspace(1,4)
xnew = np.arange(4,20)
import matplotlib.pyplot as plt
plt.plot(xnew, f2(xnew), '--')
plt.legend(['u'], loc='best')
from matplotlib import pylab
from IPython.display import Image,display
from IPython.core.display import HTML
display(Image("/home/metal-machine/Desktop/mat.png"))
plt.show()
plt.plot(xnew, f2(xnew), '--')
plt.legend(['u'], loc='best')
pylab.ylim([0,20])
pylab.xlim([0,20])
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment