Question

(i) I needed to show 3 overlapping bands, which IS NOT GOOD if three colours (with controlled opacity) are used. (ii) Then I needed hatch fill_between for one band. The code is given below. (iii) Now I am facing problems with opacity of colours while exporting in .ps or .eps. Pdf output looks fine, but while put in paper (latex;kile) they appear fainter. Anyway I only need the fig in .ps or .eps format. It can be got using 'pdf2ps' but the output .ps file in this case looks vanishingly faint in the paper (latex). PLEASE suggest a way to get .ps or .eps (vector format only) output from this. Thanks.

from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
## for Palatino and other serif fonts use:
#rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle

lcrit=0.5-np.sqrt(5)/6
l,r1,r2,r3,r4,r5,r6,zn2=np.loadtxt("stiff_reso.d",usecols=(0,1,2,3,4,5,6,7),unpack=True)

plt.plot(l,r1,linewidth=2,color="green")
plt.plot(l,r2,linewidth=2,color="green")
plt.plot(l,r3,linewidth=2,color="black")
plt.plot(l,r4,linewidth=2,color="black")
plt.plot(l,r5,linewidth=2,color="red")
plt.plot(l,r6,linewidth=2,color="red")

plt.fill_between(l,r2,r1, color='green',alpha=0.4)
plt.fill_between(l,r4,r3, color="none",hatch="/",edgecolor="k")
plt.fill_between(l,r6,r5, color='red',alpha=0.4)

plt.plot([lcrit,lcrit], [0,25], color='purple', linestyle='dashed', linewidth=2)

plt.ylabel(r"$(a_-/a_E)$",fontsize=20)
plt.xlabel(r"$\Lambda/(\kappa \rho_c)$",fontsize=20)

ax= plt.gca()

plt.xlim([0,0.14])
plt.ylim([1,5.5])
plt.text(0.122, 2.0, r'$\Lambda=\Lambda_{crit}$',rotation='vertical', fontsize=16)

p1 = Rectangle((0, 0), 1, 1, fc="green",alpha=0.4)
p2 = Rectangle((0, 0), 1, 1,hatch="//",edgecolor="k")
p3 = Rectangle((0, 0), 1, 1, fc="red",alpha=0.4)
plt.legend([p1,p2,p3], ["1st resonance band","2nd resonance band","3rd resonance   band"],loc=2)

#plt.savefig("reso_stiff.eps")
plt.savefig("reso_stiff.pdf")
plt.show()

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top