Data model method

Before we can make a chart, we'll need a SQLModel method to extract the data:

    def get_yield_by_plot(self):
        query = (
            'SELECT lab_id, plot, seed_sample, MAX(fruit) AS yield, '
            'AVG(humidity) AS avg_humidity, '
            'AVG(temperature) AS avg_temperature '
            'FROM plot_checks WHERE NOT equipment_fault '
            'GROUP BY lab_id, plot, seed_sample')
        return self.query(query)

The purpose of this chart is to find the sweet spot of temperature and humidity for each seed sample. Therefore, we need one row per plot that includes the maximum fruit measurement, average humidity and temperature at the plot column, and seed_sample. Since we don't want any bad data, we'll filter out rows that have Equipment Fault.

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.