'Add spacing between y-ticks

So I am creating a multiple line but multiple y-axis ticks are overlapping each other. So is there any stacked or different approach so can view all the ticks are visible and able to plot that. Please help me if anyone has any solution. Thanks in advance.

from pylab import *
from scipy.interpolate import make_interp_spline
from matplotlib.pyplot import margins
from matplotlib.pyplot import figure
import matplotlib as mpl
from matplotlib.colors import LinearSegmentedColormap
from matplotlib import colors

plt.rcParams['figure.dpi'] = 300
plt.rcParams["figure.figsize"] = (35,40)
col = ['purple', 'green' , 'yellow']
position = []
position_1 = []

val = am.columns
val = val.insert(0,'Week 0')
xs = np.arange(len(val))

plt.xticks(xs, val)
plt.xticks(fontsize=35)

a = colors.to_rgb(col[0]) 
b = colors.to_rgb(col[1]) 
c = colors.to_rgb(col[2])
color = [a, b, c]
cm = LinearSegmentedColormap.from_list("Custom", color, N=len(am))
k = 0

frst = am['Week 1'].values
frst.sort()

color_list = [cm(i) for i in range(11)]

c_dict = dict(zip(frst, color_list))

for k in range(len(am)):
  x= np.arange(1,6)
  y = am.iloc[k].values
  colrs = c_dict[y[0]]
  position.append(y[0])
  position_1.append(y[-1] - 10)
  
  X_Y_Spline = make_interp_spline(x, y)
  
  x = np.linspace(x.min(), x.max(), 300)
  y = X_Y_Spline(x)

  for i in range(len(x)-1):
      plt.plot(x[i:i+2], y[i:i+2], linewidth=y[i]/5, color=colrs)
      
margins(0)
plt.yticks(position, am.index.values)
plt.yticks(fontsize=35)
plt.twinx()
plt.yticks(position_1, am.index.values)
plt.yticks(fontsize=35)
plt.show()

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source