Has anyone met this kind of problem before?
The plot should be like the later one, but my computer drew like the former one.
Here is my df.info and how I draw this.
<class ‘pandas.core.frame.DataFrame’>
DatetimeIndex: 105 entries, 2020-06-02 to 2022-08-04
Data columns (total 2 columns):
Column Non-Null Count Dtype
0 rank_ic 105 non-null float64
1 30d 101 non-null float64
dtypes: float64(2)
memory usage: 2.5 KB
def plot_daily_ic(self, kind='rank_ic'):
fig = plt.figure(figsize=(10, 5*len(self.results)))
for i in range(len(self.results)):
adj_period = self.results[i]['adj_period']
ic = self.results[i]['ic'][kind].to_frame()
ic = (100 * ic).round(2)
ic.index = pd.to_datetime(ic.index)
ic['30d'] = ic[kind].rolling(window=int(20//adj_period)+1).mean()
ax = fig.add_subplot(100*(len(self.results)) + 10 + (i+1))
ax.bar(ic.index, ic[kind], alpha=0.6, width=2)
ax.plot(ic.index, ic['30d'], alpha=1, color='red')
ax.set_title(f'Adj_periods_{adj_period}: {kind} (%)', fontsize=15)
ax.legend(['30d', 'daily'], loc='upper left') # 先写plot的,再写bar的
ax.axhline(3,color='black',linestyle='--')
ax.axhline(-3,color='black',linestyle='--')
ax.fill_between(ic.index, 3, -3,color='yellow',alpha=0.4)
ax.set_ylim(-40, 40)
plt.tight_layout()
plt.show()
I used to meet this problem by starting a multiprocessing program, it seemed like a triger and it would cause my data goes wrong randomly. Then I found out it could because that I didn’t use deepcopy which contaminates my RAM. I fixed this before and all went well.
But yesterday, I went on another multiprocessing program and the problem showed up again, but after I checked all my data figures are correct, I can’t get my plot right