Subplots with Time Series

Viewed 18

I am struggling a lot with making Time Series Subplots look the way I want. I will provide what I have tried and what shortcomings they have below.

This is a sample of the data I am working with, currently in a pd data frame.

                     Price_REG1  Price_REG2  Price_REG3  Price_REG4
date                                                               
2020-01-01 00:00:00       30.83       30.83       30.83       30.83
2020-01-01 01:00:00       28.78       28.78       28.78       28.78
2020-01-01 02:00:00       28.45       28.45       28.45       28.45
2020-01-01 03:00:00       27.90       27.90       27.90       27.90
2020-01-01 04:00:00       27.52       27.52       27.52       27.52

What I want to do is to plot subplots for these four columns, one with a normal plot and one with a histogram. My plot code goes like this:

df.plot(subplots=True, color= ['grey', 'grey', 'grey', 'grey'], 
                   figsize=(6, 6),lw=0.8, xlabel='', legend=False)
plt.legend(["AA", "BBB", "AAA", "BBB"]);

Ts_plot

My only problem here rn is that the legend is only showing on the last plot for some reason.

My first Hist code:

fig, ax = plt.subplots(2, 2, sharex='col', sharey='row')

m=0
for i in range(2):
    for j in range(2):

        df.hist(column = df.columns[m], grid=False, color='grey',
                           bins = 150, ax=ax[i,j], figsize=(20, 20))
        m+=1

Hist_plot_1

Here I would like to remove titles and add legends, or change titles, "Price Region 1" etc.

My second Hist code is this:

fig, ax = df.plot(kind='hist', bins=150, subplots=True,sharex='col',sharey='row',
             title=False,layout=(2, 2), legend=True)

Hist_plot_2

Here I want to remove the y label and change the legends/add titles instead of legends.

0 Answers
Related