I have some data which I have plotted like that below. I want to take the area which I have marked in a purple box and exclude it from being plotted, basically, so that subplot 1's x axis is the interval of the sort like [1981, 1993] + [2009, 2014]
.
The code I use to do this is below:
# do figure 1
fig1, ax1 = plt.subplots(nrows=2, figsize=(8.5, 11))
# > plot 1
ax1[0].set_title('plot1')
ax1[0].set_xlabel('x')
ax1[0].set_ylabel('y1', color='tab:red')
ax1[0].plot(cumlassets.index, cumlassets.values, color='tab:red')
ax1[0].tick_params(axis='y', labelcolor='tab:red')
# > plot2
ax1a = ax1[0].twinx()
ax1a.set_ylabel('y2', color='tab:blue')
ax1a.plot(ail_2016.index, ail_2016.values, color='tab:blue')
ax1a.tick_params(axis='y', labelcolor='tab:blue')
# > s
sns.barplot(x='x', y='y', hue='hue', dodge=False, data=res, ax=ax1[1])
ax1[1].set_title('plot2')
ax1[1].set_xticklabels(res['x'].values, rotation='vertical', ha='center')
ax1[1].set_xlabel('x')
ax1[1].set_ylabel('y')
fig1.tight_layout()
I'll note that the subplot on top already does some funky ax[0].twinx()
stuff to permit the plotting of the two lines on the same plot with different scales.
It'd also be fantastic to find a way to have this done on the bottom bar plot, which wants to do something similar. The way I have it set up right now is a bit hacky, with an intermediate point in the data with {'x': '. . .', 'y': 0}
.
EDIT: Regarding the bar plot, I've decided to just suppress the ticks.