我有一个简单的条形图,上面有一个折线图。
import numpy as np
import matplotlib.pyplot as plt
x = np.array(["one", "two", "three", "four"])
a = np.array([1, 2, 3, 4])
b = np.array([2, 4, 3, 1])
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.bar(x, a, color="g")
ax2.plot(x, b, color="r")
# Problem is here.
ax1.set_xticklabels(x, rotation="vertical", size=12)
plt.show()
当我运行它时,它工作正常。但我收到这个警告:
"""
<ipython-input-65-9b40369b760b>:15: UserWarning: FixedFormatter should only be used together with
FixedLocator
ax1.set_xticklabels(x, rotation="vertical", size=12)
"""
我需要知道的是如何避免这个警告。
jeck猫
相关分类