如何防止Matplotlib图中的Y轴tick标签超过?
嗨,我想从CSV文件中绘制图形,该图形包括许多独特的值500值)。绘制图形时,y轴tick标签互相运行,我希望每个值都存在于y轴上。我不想跳过值。任何人都可以建议我如何使我的图形在整齐地读取y轴上的所有这500个值。
fig, ax = plt.subplots()
#plt.figure(figsize=(800/my_dpi, 800/my_dpi), dpi=my_dpi)
plt.rcParams["figure.figsize"] = [7.00, 5.50]
plt.rcParams["figure.autolayout"] = True
space = 3
dash_len = 3
ax.set_facecolor("yellow")
ax.plot(sorted(failed_it),failed_p,color='r',linestyle='dashed',dashes=(dash_len,
space),alpha=0.7, linewidth = 1,marker='s', markerfacecolor='red', markersize=4)
ax.plot(sorted(passed_it),passed_p,color='g',linestyle='dashed',dashes=(dash_len,
space),alpha=0.7, linewidth = 1,marker='d', markerfacecolor='blue', markersize=4)
plt.style.use('fivethirtyeight')
plt.xlabel("Iteration_Rate",fontweight="bold",fontsize=9)
plt.ylabel("Trigger_Port,VLAN",fontweight="bold")
plt.title("Platform="+str(keyss[3])+",Build="+ str(list1_8112[0][1])+",Trigger-
SystemRestart",fontweight="bold")
size = fig.get_size_inches()*fig.dpi
print(size)
ax = plt.gca()
ax.set_xticks(np.arange(0,6,1))
ax.xaxis.set_label_coords(1.07, -0.025)
ax.xaxis.set_major_locator(plt.MaxNLocator(100))
` plt.yticks(port_VLAN_8112,ha='right',fontsize=8)
plt.xticks(it_rate_8112[::20],ha='right',fontsize=8)
plt.margins(0)
ax.grid('on')
plt.show()
fig = plt.figure()
Hi everyone i am trying to plot a graph from a csv file which includes many unique values specially for y axis(close to 500 values).When graph is plotted y axis tick labels are over running each other and i want each values to be present on y-axis .I dont want to skip values. Can anyone suggest me how can i make my graph having all these 500 values on y-axis read neatly.
fig, ax = plt.subplots()
#plt.figure(figsize=(800/my_dpi, 800/my_dpi), dpi=my_dpi)
plt.rcParams["figure.figsize"] = [7.00, 5.50]
plt.rcParams["figure.autolayout"] = True
space = 3
dash_len = 3
ax.set_facecolor("yellow")
ax.plot(sorted(failed_it),failed_p,color='r',linestyle='dashed',dashes=(dash_len,
space),alpha=0.7, linewidth = 1,marker='s', markerfacecolor='red', markersize=4)
ax.plot(sorted(passed_it),passed_p,color='g',linestyle='dashed',dashes=(dash_len,
space),alpha=0.7, linewidth = 1,marker='d', markerfacecolor='blue', markersize=4)
plt.style.use('fivethirtyeight')
plt.xlabel("Iteration_Rate",fontweight="bold",fontsize=9)
plt.ylabel("Trigger_Port,VLAN",fontweight="bold")
plt.title("Platform="+str(keyss[3])+",Build="+ str(list1_8112[0][1])+",Trigger-
SystemRestart",fontweight="bold")
size = fig.get_size_inches()*fig.dpi
print(size)
ax = plt.gca()
ax.set_xticks(np.arange(0,6,1))
ax.xaxis.set_label_coords(1.07, -0.025)
ax.xaxis.set_major_locator(plt.MaxNLocator(100))
` plt.yticks(port_VLAN_8112,ha='right',fontsize=8)
plt.xticks(it_rate_8112[::20],ha='right',fontsize=8)
plt.margins(0)
ax.grid('on')
plt.show()
fig = plt.figure()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找更改tick频率。
您可以通过打电话来轻松执行此操作,
您可以在此处看到很棒的示例:更改matplotlib中的tick频率
You are looking for changing the ticks frequency.
You can easily do that by calling
You can see great examples here: Change Tick Frequency in Matplotlib