Как закрыть промежутки между барами в гистограмме, отображаемой из-за отсутствия / недоступности дат (ось X) в кадре данных? - PullRequest
0 голосов
/ 29 апреля 2020

Bar chart where X axis has denotes dates

Если вы внимательно наблюдаете, между барами гистограммы есть промежутки. Это из-за недоступных дат в кадре данных. Я не хочу промежутков между барами. Как решить эту проблему?

следующий мой код:

Создание области и гистограммы

fig, axs = plt.subplots(2, sharex = True, gridspec_kw = {'hspace': 0}, figsize = (10,6) );
# Here axs has become an array in other words a numpy array
# gridspec_kw = {'hspace': 0} is to remove the space between 2 subplots

plt.subplots_adjust(left= 0.010, right = 0.85, wspace = 0)

# Shifting the location of yticks to right:
for ax in axs:
    ax.yaxis.tick_right()

axs[0].fill_between(reli_df['Date'], reli_df['Close'], color="skyblue", alpha=0.4)
axs[0].plot(reli_df['Date'], reli_df['Close'])
axs[0].yaxis.set_label_position("right")
axs[0].set_ylabel('Share Value/Price')

# Creating Bar chart

axs[1].bar(reli_df['Date'], reli_df['Volume'], width = 0.999, edgecolor = 'black', lw = 0.2, color = color_list)
# if width > 1 then bars overlapp
axs[1].yaxis.set_label_position("right")
axs[1].set_ylabel('Volume')

#reli_df['Date'] = reli_df['Date'].map(mdates.date2num)

# axs[0].xaxis_date()

date_form = DateFormatter("%Y-%b-%d")
axs[0].xaxis.set_major_formatter(date_form)
...