Fill area between 2 lines [SOLVED]

Hi, thank you for the fast reply. If was very helpful.

I managed to achive what I was looking for. See below:

What I did I create a 3rd line “-------” (‘senkou_c’). I calculated the line below like that.

		df['senkou_c'] = np.nan
		for index, row in df.iterrows():
			if row['senkou_a'] < row['senkou_b']:
				df.at[index,'senkou_c'] = row['senkou_a']
			elif row['senkou_a'] > row['senkou_b']:
				df.at[index,'senkou_c'] = row['senkou_b']
			elif row['senkou_a'] == row['senkou_b']:
				df.at[index,'senkou_c'] = row['senkou_b']

And then I plotted the like below:

		if self.df.__contains__('senkou_c'):
			trace = go.Scatter(
				x = self.df['date'],
				y = self.df['senkou_c'],
				name = "------",
				line = dict(color = ('rgba(255, 255, 255, 0)')))
			self.data.append(trace)

		if self.df.__contains__('senkou_b'):
			trace = go.Scatter(
				x = self.df['date'],
				y = self.df['senkou_b'],
				fill = 'tonexty',
				name = "Senkou B",
				fillcolor = 'rgba(255, 0, 0, 0.3)',
				line = dict(color = ('rgba(255, 0, 0, 0.3)')))
			self.data.append(trace)

		if self.df.__contains__('senkou_c'):
			trace = go.Scatter(
				x = self.df['date'],
				y = self.df['senkou_c'],
				name = "------",
				line = dict(color = ('rgba(255, 255, 255, 0)')))
			self.data.append(trace)

		if self.df.__contains__('senkou_a'):
			trace = go.Scatter(
				x = self.df['date'],
				y = self.df['senkou_a'],
				fill = 'tonexty',
				name = "Senkou A",
				fillcolor = 'rgba(0, 255, 0, 0.3)',
				line = dict(color = ('rgba(0, 255, 0, 0.3)')))
			self.data.append(trace)

I hope this will help other people looking for something similar.

Thank you,
Alex

1 Like