qxplots.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import matplotlib.gridspec as gridspec
  4. import makeqx as mkq
  5. def plot_qx(q_x, with_dig=True, with_swatch=True):
  6. fig = plt.subplots(2,1, figsize=(8,2))
  7. uni = np.linspace(0, q_x.size, q_x.size, endpoint=False)
  8. q_xd = mkq.digitize_qx(q_x)
  9. ax = plt.subplot(211)
  10. if q_x.size >=100:
  11. gratim = np.tile(q_x, (int(q_x.size/40),1))
  12. else:
  13. gratim = np.tile(q_x, (int(q_x.size/4),1))
  14. #ax.axis('tight')
  15. ax.axis('off')
  16. ax.set_axis_off()
  17. ax.set_xlim(0,q_x.size)
  18. ax.xaxis.set_label_position('top')
  19. ax.xaxis.tick_top()
  20. ax.imshow(gratim, cmap='binary_r')
  21. ax1 = plt.subplot(212)
  22. #ax1.imshow(gratim, cmap='binary_r')
  23. ax1.plot(uni, q_x, '--', linewidth=1 )
  24. ax1.plot(uni, q_xd, linewidth=0.8 )
  25. ax1.set_ylim(-0.1,1.1)
  26. ax1.set_xlim(0,q_x.size)
  27. ax1.set_xlabel('Layer Index')
  28. #ax1.xaxis.set_label_position('top')
  29. #ax1.xaxis.tick_top()
  30. plt.subplots_adjust(wspace=0, hspace=0)
  31. plt.tight_layout()
  32. def plotrsrp(Rs, Rp, lam_low=400, lam_high=1200, lam_pts=100, ang_low=0,
  33. ang_high=90, ang_pts=25):
  34. """TODO: Docstring for plotrsrp.
  35. :Rs: TODO
  36. :Rp: TODO
  37. :lam_low: TODO
  38. :lam_high: TODO
  39. :lam_pts: TODO
  40. :ang_low: TODO
  41. :ang_high: TODO
  42. :ang_pts: TODO
  43. :returns: TODO
  44. """
  45. fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10,4))
  46. for idx, ax in enumerate(axes.flat):
  47. if idx == 0:
  48. im = ax.imshow(Rs, interpolation='bicubic', extent=[lam_low,
  49. lam_high, ang_low, ang_high],
  50. vmin=0, vmax=1, cmap="hot", aspect=4)
  51. ax.set_xlabel('Wavelength (nm)')
  52. ax.set_ylabel('Angle (Degrees)')
  53. ax.set_title('s - pol')
  54. else:
  55. im = ax.imshow(Rp, interpolation='bicubic', extent=[lam_low,
  56. lam_high, ang_low, ang_high],
  57. vmin=0, vmax=1, cmap="hot", aspect=4)
  58. ax.set_xlabel('Wavelength (nm)')
  59. ax.set_ylabel('Angle (Degrees)')
  60. ax.set_title('p - pol')
  61. plt.tight_layout()
  62. fig.colorbar(im, ax=axes.ravel().tolist(), shrink=0.3)