带有两个 y 尺度的 Seaborn despine (twinx)
Seaborn despine with two y-scales (twinx)
如何避免 seaborn.despine
将我的两个 y 尺度都放在绘图的左侧?
到目前为止我想到的最好的是:
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
sns.set_style("white")
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
ax2 =ax.twinx()
ax2.plot(100*np.random.rand(10))
sns.despine(ax=ax, right=True, left=True)
sns.despine(ax=ax2, left=True, right=False)
但任何其他组合都不会取消 y 轴或将右轴放在左侧。
上面的输出:(期望的输出没有书脊,只有左右两边的数字)
我猜这就是你想要的。
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
sns.set_style("white")
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
ax2 =ax.twinx()
ax2.plot(100*np.random.rand(10))
sns.despine(ax=ax, right=True, left=True)
sns.despine(ax=ax2, left=True, right=False)
ax2.spines['right'].set_color('white')
如何避免 seaborn.despine
将我的两个 y 尺度都放在绘图的左侧?
到目前为止我想到的最好的是:
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
sns.set_style("white")
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
ax2 =ax.twinx()
ax2.plot(100*np.random.rand(10))
sns.despine(ax=ax, right=True, left=True)
sns.despine(ax=ax2, left=True, right=False)
但任何其他组合都不会取消 y 轴或将右轴放在左侧。
上面的输出:(期望的输出没有书脊,只有左右两边的数字)
我猜这就是你想要的。
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
sns.set_style("white")
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
ax2 =ax.twinx()
ax2.plot(100*np.random.rand(10))
sns.despine(ax=ax, right=True, left=True)
sns.despine(ax=ax2, left=True, right=False)
ax2.spines['right'].set_color('white')