matplotlib画图,求教一下坐标轴刻度文字大小无法调整是什么原因?

jiezouluxian 2021-03-04 04:05:03
求教一下坐标轴刻度文字大小无法调整是什么原因?
我用的命令是:
host.tick_params(axis="left", labelsize=14)
par1.tick_params(axis="y", labelsize=14)
该怎么修改?

from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA

host = host_subplot(111, axes_class=AA.Axes)
pyplot.subplots_adjust(right=0.9)
par1 = host.twinx()
par2 = host.twinx()
offset = 60
new_fixed_axis = par2.get_grid_helper().new_fixed_axis
par2.axis["right"] = new_fixed_axis(loc="right",
axes=par2,
offset=(offset, 0))
par1.axis["right"].toggle(all=True)
par2.axis["right"].toggle(all=True)
host.set_xlim(0, 30)
host.set_ylim(-150, 150)

host.set_xlabel('Time(s)')
host.set_ylabel('Torque(N.m)')
par1.set_ylabel('Vehicle speed(km/h)')
par2.set_ylabel("Pedal degree(%)")

p1, = host.plot([0, 1, 2], [0, 1, 2],'ko-',ms=8,markevery=20, markerfacecolor='none', label="Engine torque(N.m)")
p11, = host.plot([0, 1, 2], [4, 5, 6], 'kx-',ms=8,markevery=20,markerfacecolor='none',label="Motor torque(N.m)")
p2, = par1.plot([0, 1, 2], [0, 3, 2], '^-',ms=8, markevery=20, markerfacecolor='none',label="Temperature")
p3, = par2.plot([0, 1, 2], [50, 30, 15], 's-',ms=8, markevery=20, markerfacecolor='none',label="Velocity")

par1.set_ylim(0, 60)
par2.set_ylim(0, 100)

host.legend(fontsize=12)

host.axis["left"].label.set_color(p1.get_color())
host.axis["left"].label.set_fontsize(14)
host.axis["bottom"].label.set_fontsize(14)
par1.axis["right"].label.set_color(p2.get_color())
par1.axis["right"].label.set_fontsize(14)
par2.axis["right"].label.set_color(p3.get_color())
par2.axis["right"].label.set_fontsize(14)
host.tick_params(axis="left", labelsize=14)
par1.tick_params(axis="y", labelsize=14)
# for tick in host.xaxis.get_major_ticks():
# tick.label.set_fontsize(30)
# host.xaxis.set_tick_params(size=14)
# pyplot.xticks(range(0,30,5),fontsize=30)
# pyplot.yticks(range(0,200,50),fontsize=30)
pyplot.show()
...全文
124 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

37,742

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧