PyPlot:如何更改xlabel背景颜色以及xlabel在绘图上方?

时间:2018-01-21 13:34:47

标签: python matplotlib julia

How to give the xlabel background a yellow color with alpha

如何为xlabel背景提供黄色?当我使用bbox时,xlabel就在情节的后面。如何把它带到前面?我试着调整zorder,但是没有为轴标签设置zorder。

Python或Julia代码会很有帮助。

这是我目前正在使用的代码:

fig=figure(4)
ax = gca()

xlabel("Rotor position [mm]", horizontalalignment="right", x=1.0, color="gray", bbox=Dict("facecolor"=>"yellow","edgecolor"=>"None"))
ylabel("Force [N]",fontdict=font1, horizontalalignment="right", y=1.0, fontdict=font1, color="gray")
ax[:invert_xaxis]()

plot(x_rotor,Fx_net_off,"--",label=L"F$_{\rm total}: 0\ \rm AT$")
plot(x_rotor,Fx_net_pos,label=L"F$_{\rm total}: +100\ \rm AT$")
plot(x_rotor,Fx_net_neg,label=L"F$_{\rm total}: -100\ \rm AT$")
font1 = Dict("color"=>"k")

ax[:spines]["top"][:set_visible](false) # Hide the top edge of the axis
ax[:spines]["right"][:set_visible](false) # Hide the right edge of the axis
ax[:spines]["left"][:set_position]("center") # Move the right axis to the center
ax[:spines]["bottom"][:set_position]("center") # Most the bottom axis to the center
ax[:xaxis][:set_ticks_position]("bottom") # Set the x-ticks to only the bottom
ax[:yaxis][:set_ticks_position]("left") # Set the y-ticks to only the left

ax[:spines]["left"][:set_color]("gray")
ax[:tick_params](axis="y", colors="gray")

ax[:spines]["bottom"][:set_color]("gray")
ax[:tick_params](axis="x", colors="gray")

PyPlot.xticks([x_rotor[1],0.1,0,-0.1,x_rotor[end]])

xlim([0.2,-0.2])

fig[:canvas][:draw]() # Update the figure

0 个答案:

没有答案