【发布时间】:2018-12-03 19:02:47
【问题描述】:
【问题讨论】:
-
那是哪个包?您需要一些解决方法,因为您的问题的一般答案是“否”。
-
是蒙特卡洛奇异谱分析,在这个 repo github.com/VSainteuf/mcssa
标签: python matplotlib
【问题讨论】:
标签: python matplotlib
由于将内容从一个图形复制到另一个图形非常困难,并且通常不建议这样做,我建议您编写自己版本的mcssa package 的绘图功能。
所以不是
m = MCSSA(...)
m.run_mcssa(...)
m.plot()
您可以复制以下函数以将结果绘制到您指定的轴上
def ssaplot(mc_ssa, freq_rank=True, ax=None):
ax = ax or plt.gca()
ax.set_yscale('log')
ax.set_ylabel('Variance')
ax.set_title('M: {}; cov: {}'.format(mc_ssa.M, mc_ssa.algo))
if not freq_rank:
x = [i for i in range(mc_ssa.M)]
y = mc_ssa.values
ax.set_xlabel('Eigenvalue Rank')
ax.plot(y, marker='s', linewidth=0, color='r')
else:
x = mc_ssa.freqs[mc_ssa.freq_rank]
y = mc_ssa.values[mc_ssa.freq_rank]
ax.set_xlabel('Frequency (Cycle/t. unit)')
ax.plot(x, y, marker='s', linewidth=0, color='r')
if mc_ssa.ismc:
errors = np.array(mc_ssa.stats.iloc[3:5, :])
mean_suro = np.array(mc_ssa.stats.iloc[0, :])
ax.errorbar(x, y=mean_suro, yerr=errors, fmt=None,
ecolor='k', elinewidth=.5, capsize=2.5)
ax.set_title('M: {}; g: {}; a: {}; Ns: {}'.format(mc_ssa.M,
mc_ssa.ar.gamma,
mc_ssa.ar.alpha,
mc_ssa.n_suro))
像这样使用它
import numpy as np
import matplotlib.pyplot as plt
from mcssa import MCSSA # probably(?)
m1 = MCSSA(...)
m1.run_mcssa(...)
m2 = MCSSA(...)
m2.run_mcssa(...)
fig, (ax1, ax2) = plt.subplots(2)
ssaplot(m1, ax=ax1)
ssaplot(m2, ax=ax2)
plt.show()
【讨论】:
我认为您可以将图形输出存储在变量中,并像通常使用 matplotlib 一样继续添加额外的图。 Here 是与您所要求的内容类似的帖子。
【讨论】: