Python 一个阵列子批次中的不同y轴
我不知道如何告诉matplotlib在数组子地块的一个特殊子地块中使用不同的轴:Python 一个阵列子批次中的不同y轴,python,matplotlib,subplot,Python,Matplotlib,Subplot,我不知道如何告诉matplotlib在数组子地块的一个特殊子地块中使用不同的轴: import numpy as np import matplotlib.pyplot as plt import seaborn as sns def plotter(): y=np.random.rand(10) y1 = np.random.rand(10)*100 x = np.arange(len(y)) f, axarr = plt.subplots(2,2,shar
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
def plotter():
y=np.random.rand(10)
y1 = np.random.rand(10)*100
x = np.arange(len(y))
f, axarr = plt.subplots(2,2,sharex=True)
axarr[0][0].errorbar(x,y,)
axarr[0][0].errorbar(x,y1)
axarr[1][1].twinx()
axarr[1][1].errorbar(x,y)
axarr[1][1].errorbar(x,y1)
plt.show()
plotter()
这使得:
问题是,我的一个数据集要大上百倍,所以在同一个y轴上绘制它们是无用的。我希望右下面板(仅此面板)有一个y轴,在绘图右侧范围为(0,10),在另一侧范围为(0100)。蓝线应以右(0,10)y轴表示,而蓝线应以左(0100)y轴表示。一种方法是:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
def plotter():
y=np.random.rand(10)
y1 = np.random.rand(10)*100
x = np.arange(len(y))
f, axarr = plt.subplots(2,2,sharex=True)
axarr[0][0].errorbar(x,y,)
axarr[0][0].errorbar(x,y1)
axarr[1][1].errorbar(x,y)
ax2 = axarr[1][1].twinx()
ax2.plot(x,y1, 'r')
#ax2.tick_params('y', colors='r')
plt.show()
plotter()
因此:
一种方法是:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
def plotter():
y=np.random.rand(10)
y1 = np.random.rand(10)*100
x = np.arange(len(y))
f, axarr = plt.subplots(2,2,sharex=True)
axarr[0][0].errorbar(x,y,)
axarr[0][0].errorbar(x,y1)
axarr[1][1].errorbar(x,y)
ax2 = axarr[1][1].twinx()
ax2.plot(x,y1, 'r')
#ax2.tick_params('y', colors='r')
plt.show()
plotter()
因此:
我还是不明白你想做什么。@SamMarinelli现在清楚了吗?我明白了。不幸的是,我不知道怎么做。我仍然不明白你想做什么。@SamMarinelli现在清楚了吗?我明白了。不幸的是,我不知道怎么做。