1

So I am trying to set up a chart in python to show the development of an inter-month spread over the year (i.e. Oct/Nov 2015, Oct/Nov 2016, and so on).

Currently when I plot, it shows me the whole timeline on the x-axis from 2015 to however far I go.

enter image description here

Preferably I would like to show number of days rather than actual date on X-axis, since they are all over a year.

I've tried the following code:

#Fetching curve
curve_name = 'Oct/Nov'
OctNov = get_forward_curve_history(name=curve_name, start_date='2019-01- 
01', end_date=date)

#plotting spread
Oct/Nov = Med4.loc['2019-10-01':'2019-10-31'].mean() - JKM5.loc['2019-11- 
01':'2019-11-30'].mean()

Oct/Nov.plot()

#legend and grid commands
plt.gca().legend(('Oct/Nov17','Oct/Nov18','Oct/Nov19'))
plt.grid()
plt.show()

I would expecting something like the below, where we can see different years but on the same X-axis scale (roughly 365 days):

enter image description here

Geekfish
  • 2,173
  • 23
  • 28
Asd13
  • 43
  • 8

1 Answers1

0

If I understand correctly you just want to plot a bunch of years worth of data on the same graph?

If so you want to either use the plt.hold(True) option and just add the to the figure again and again then show at the end or ready all the data and plot it all at once.

It is very hard to produce any code without the original data but this may help:

Python equivalent to 'hold on' in Matlab

j.t.2.4.6
  • 178
  • 1
  • 11
  • Hi, I tried this but after inserting the above command I get the same result. I insert the command just before 'plt.gca().legends' – Asd13 Apr 17 '19 at 15:40
  • What happens if you get rid of that hold command and just split each dataset so you have the 1vs2 and the day of effective date1 as two seperate arrays. They just plot all of the 1vs2 data against one of the date arrays. This should essentially do what you want although it won't be super neat. – j.t.2.4.6 Apr 17 '19 at 16:10
  • (Sorry been afk) Sorry I meant the hold comment I suggested. Can you post an example of one of the datasets? Is it just two columns one with dates and one with numbers? – j.t.2.4.6 Apr 18 '19 at 08:04