Home > Mobile >  Uneven grid when plotting date in plt
Uneven grid when plotting date in plt

Time:12-25

I want to plot variable by date, days and month. Grid is uneven when month is changing. How to force size of grid in this case?

Data is loaded via Pandas, as DataFrame. ga =

Refference  Organic_search  Direct  Date
0   0   0   0   2021-11-22
1   0   0   0   2021-11-23
2   0   0   0   2021-11-24
3   0   0   0   2021-11-25
4   0   0   0   2021-11-26
5   0   0   0   2021-11-27
6   0   0   0   2021-11-28
7   42  19  35  2021-11-29
8   69  33  48  2021-11-30
9   107 32  35  2021-12-01
10  62  30  26  2021-12-02
11  20  26  30  2021-12-03
12  22  22  20  2021-12-04
13  40  41  20  2021-12-05
14  14  39  26  2021-12-06
15  18  25  34  2021-12-07
16  8   21  13  2021-12-08
17  11  21  17  2021-12-09
18  23  27  20  2021-12-10
19  46  26  17  2021-12-11
20  29  42  20  2021-12-12
21  122 37  19  2021-12-13
22  97  25  29  2021-12-14
23  288 51  39  2021-12-15
24  96  29  26  2021-12-16
25  51  25  36  2021-12-17
26  23  16  21  2021-12-18
27  47  32  10  2021-12-19


code:


fig, ax = plt.subplots(figsize = (15,5))
ax.plot(ga.date, ga.refference)
ax.set(xlabel = 'Data', 
       ylabel = 'Ruch na stronie')

date_form = DateFormatter('%d/%m')
ax.xaxis.set_major_formatter(date_form)

enter image description here

  • Related