禁用海底图中的轴标签和刻度

时间:2020-01-27 18:32:12

标签: python matplotlib seaborn

我正在使用seaborn来绘制具有xticks和轴标签的现有图。 Seaborn覆盖了这些元素。有没有办法禁用此行为?

让我通过以下示例演示我的问题:

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

# Original plot
x = np.array([0]*5 + [1]*5)
y = np.random.randint(0, 10, 10)

plt.figure()
plt.scatter(x, y)
plt.xticks([0, 1], ["Myxtick1", "Myxtick2"])
plt.xlabel("Myxlabel")
plt.ylabel("Myylabel")
plt.xlim([-0.5, 1.5])

enter image description here

现在,我将使用seaborn绘制我的原始图形:

# Overlay plot
tips = sns.load_dataset("tips")
sns.boxplot(data=tips, x="time", y="tip")

enter image description here

如所示,我的xtick和xlabel不见了。有没有一种方法可以通过将参数传递给seaborn.boxplot函数来避免这种情况?我知道在调用seaborn.boxplot之后可以使用plt.xticks,plt.xlabel / ylabel,但我希望有另一种方法。

谢谢

0 个答案:

没有答案
相关问题