0

I am trying to draw subplots. I need to put labels at specific points as given in the code using scatter. The problem is I can see that the circular label is coming in the left most plot but not in middle and right panels. The data file are availbale here

My program `

from pylab import *
from matplotlib import *
import matplotlib as mpl
import os

from global_tools import *


path = os.getcwd()+"/"


print("Plotting allowed range...")

fig = plt.figure(figsize=[15,5])
ax = fig.add_subplot(1,3,1)

ax.set_xscale('log')
ax.set_yscale('linear')
pylab.xlim([1e-15, 1e-13])
pylab.ylim([180, 265])

lst_colors = ['#489E00', '#FEE08B', '#D53E4F', '#0066CC', '#489E00', '#FF3333', '#000000']

lst_limits = Read_Data_File(path+"12.txt")
lst_V = [10**lst_limits[0][j] for j in range(len(lst_limits[0]))]
lst_dcp = [lst_limits[1][j] for j in range(len(lst_limits[1]))]

lst_limits2 = Read_Data_File(path+"11.txt")
lst_V2 = [10**lst_limits2[0][j] for j in range(len(lst_limits2[0]))]
lst_dcp2 = [lst_limits2[1][j] for j in range(len(lst_limits2[1]))]

lst_limits3 = Read_Data_File(path+"13.txt")
lst_V3 = [10**lst_limits3[0][j] for j in range(len(lst_limits3[0]))]
lst_dcp3 = [lst_limits3[1][j] for j in range(len(lst_limits3[1]))]

#circle = plt.Circle((2.11678e-14,223), radius=0.4)
#ax.set_aspect(1)
#ax.add_artist(circle)

ax.plot([2.11678e-14,223], 'og', fillstyle = 'full', ms=10.0)

ax.fill(lst_V, lst_dcp, edgecolor=None, facecolor=lst_colors[0], zorder=0, alpha=0.7)

ax.fill(lst_V2, lst_dcp2, edgecolor=None, facecolor=lst_colors[1], zorder=0, alpha=0.95)

ax.fill(lst_V3, lst_dcp3, edgecolor=None, facecolor=lst_colors[2], zorder=0, alpha=0.7)

ax.scatter(2.11678e-14,223, s=10, facecolors='white', edgecolors='white')


#####-------------------------2nd subplot----------------------------------#######

ax2 = fig.add_subplot(1,3,2)

ax2.set_xscale('log')
ax2.set_yscale('linear')
pylab.xlim([1e-15, 1e-13])
pylab.ylim([180, 265])

lst_limits4 = Read_Data_File(path+"21.txt")
lst_V4 = [10**lst_limits4[0][j] for j in range(len(lst_limits4[0]))]
lst_dcp4 = [lst_limits4[1][j] for j in range(len(lst_limits4[1]))]

lst_limits5 = Read_Data_File(path+"22.txt")
lst_V5 = [10**lst_limits5[0][j] for j in range(len(lst_limits5[0]))]
lst_dcp5 = [lst_limits5[1][j] for j in range(len(lst_limits5[1]))]

lst_limits6 = Read_Data_File(path+"23.txt")
lst_V6 = [10**lst_limits6[0][j] for j in range(len(lst_limits6[0]))]
lst_dcp6 = [lst_limits6[1][j] for j in range(len(lst_limits6[1]))]

ax2.fill(lst_V4, lst_dcp4, edgecolor=None, facecolor=lst_colors[1], zorder=20, alpha=0.95)

ax2.fill(lst_V5, lst_dcp5, edgecolor=None, facecolor=lst_colors[0], zorder=0, alpha=0.7)

ax2.fill(lst_V6, lst_dcp6, edgecolor=None, facecolor=lst_colors[2], zorder=20, alpha=0.7)

ax2.scatter(1.4967e-14,223, s=10, facecolors='white', edgecolors='white')

ax2.tick_params(left = True, right = False , labelleft = False ,
                labelbottom = True, bottom = True)


#####-------------------------3rd subplot----------------------------------#######

ax3 = fig.add_subplot(1,3,3)

ax3.set_xscale('log')
ax3.set_yscale('linear')
pylab.xlim([1e-15, 1e-13])
pylab.ylim([180, 265])

lst_limits7 = Read_Data_File(path+"31.txt")
lst_V7 = [10**lst_limits7[0][j] for j in range(len(lst_limits7[0]))]
lst_dcp7 = [lst_limits7[1][j] for j in range(len(lst_limits7[1]))]

lst_limits8 = Read_Data_File(path+"32.txt")
lst_V8 = [10**lst_limits8[0][j] for j in range(len(lst_limits8[0]))]
lst_dcp8 = [lst_limits8[1][j] for j in range(len(lst_limits8[1]))]

lst_limits9 = Read_Data_File(path+"33.txt")
lst_V9 = [10**lst_limits9[0][j] for j in range(len(lst_limits9[0]))]
lst_dcp9 = [lst_limits9[1][j] for j in range(len(lst_limits9[1]))]

ax3.fill(lst_V7, lst_dcp7, edgecolor=None, facecolor=lst_colors[1], zorder=20, alpha=0.95)

ax3.fill(lst_V8, lst_dcp8, edgecolor=None, facecolor=lst_colors[0], zorder=0, alpha=0.7)

ax3.fill(lst_V9, lst_dcp9, edgecolor=None, facecolor=lst_colors[2], zorder=20, alpha=0.7)

ax3.scatter(1.12675e-14,223, s=10, facecolors='white', edgecolors='white')

ax3.tick_params(left = True, right = False, labelleft = False ,labelbottom = True, bottom = True)

pylab.savefig("test.pdf", bbox_inches='tight', dpi=200)
plt.show()
plt.close()


# In[4]:


path = os.getcwd()+"/"






`

I do not understand why the other two labels are not coming. Kindly help.

Masoom
  • 13
  • 3
  • Please remove all `import *` from your code, as this creates a big mess, making it hard to know which command comes from where. Please remove `import pylab` as that is only intended for very old code. You should just `from matplotlib import plt` to have all functionality. Change calls such as `pylab.xlim(...)` to `ax2.set_xlim(...)` to clearly indicate which subplot should be updated. You can use `ax2.scatter(...., zorder=21)` and `ax3.scatter(...., zorder=21)` to place the scatter plot on top of the fills with z-order 20. – JohanC Dec 23 '22 at 14:20
  • Thanks a lot using zorder=21 works fine. I had been stuck due to this for some time. Thanks again, and I am sorry for all the unnecessary imports. – Masoom Dec 24 '22 at 02:50

0 Answers0