Drawing multiple lines on a single chart in an app

Hi Everyone, I would like to draw an arbitrary number of lines on a single plot within my app. I am using the getattr function to get my plot references and I have a feeling this is where I am tripping up. This mess is because I want to be able to scale this app to an arbitrary number of plots in this section.

The issue is that only the last data set in my list of wellsites shows up on the plot. It almost looks like all lines are being drawn on top of each other.

When I am testing in a single script (not from within the Flask webapp), I do not have this trouble. It’s only here that I am seeing this

class PlottingApp(VBox):

···

extra_generated_classes = [[“PlottingApp”, “PlottingApp”, “VBox”]]

plot1 = Instance(Plot)
plot2 = Instance(Plot)
plot3 = Instance(Plot)
source = Instance(ColumnDataSource)

def make_plots(self):


df = self.source.to_df()

for i in range(1, 3 + 1):

p = figure(plot_width=1200,

plot_height=300,
title_text_font_size=‘12pt’,
x_axis_type=‘datetime’,
x_range=None,
tools=toolset)
if i == 1:
pass
else:
headplot = getattr(self, ‘plot{}’.format(1))
x_range = getattr(headplot, ‘x_range’)
p.x_range = x_range

for ws in my_wellsites:
try:

ws_data = df[df[‘wellsite’] == ws][y_val]
p.line(x=dti, y=ws_data.values, source=self.source,

color=my_wellsites[ws][‘color’],
legend=ws,
line_width=1,
line_alpha=0.6
)
setattr(self, ‘plot{}’.format(i), p)
except KeyError:
print ‘Key Error!!! at {}’.format(ws)
pass
print ‘setting plot attribute for plot {}’.format(i)
setattr(self, ‘plot{}’.format(i), p)