在Y键之间添加间距
因此,我正在创建多条线,但多个 y 轴刻度线彼此重叠。那么是否有任何堆叠或不同的方法,以便可以查看所有刻度线是否可见并能够绘制出来。如果有人有任何解决方案,请帮助我。提前致谢。
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()
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()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论