[英]Pcolormesh secondary axis ticks missing when set as 'in'
I have an issue when setting the tick direction to direction='in'
when using the secondary_xaxis
function.在使用
secondary_xaxis
function 时将刻度方向设置为direction='in'
时出现问题。 They appear only when set to out
它们仅在设置为
out
时出现
Here is a MWE:这是一个MWE:
import matplotlib.pyplot as plt
import numpy as np
def invert(x):
return (x+1)**-1
dx, dy = 0.15, 0.05
# generate 2 2d grids for the x & y bounds
y, x = np.mgrid[slice(-3, 3 + dy, dy),
slice(-3, 3 + dx, dx)]
z = (1 - x / 2. + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2)
z = z[:-1, :-1]
z_min, z_max = -np.abs(z).max(), np.abs(z).max()
fig = plt.figure()
ax = fig.add_subplot(111)
ax.pcolormesh(x, y, z, cmap='RdBu', vmin=z_min, vmax=z_max)
ax.set_xlabel(r'normal')
ax.tick_params(direction='in')
secax = ax.secondary_xaxis('top', functions=(invert, invert))
secax.set_xlabel(r'invert')
secax.tick_params(direction='in')
Here is the output:这是 output:
But setting secax.tick_params(direction='out')
gives the correct output:但是设置
secax.tick_params(direction='out')
给出了正确的 output:
Anyone has an idea how to solve that?任何人都知道如何解决这个问题?
Thanks谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.