+ return maxtemp > mintemp;
+}
+
+static void plot_single_temp_text(struct graphics_context *gc, int sec, int mkelvin)
+{
+ int deg;
+ const char *unit;
+ static const text_render_options_t tro = {12, 0.2, 0.2, 1.0, LEFT, TOP};
+ temperature_t temperature = { mkelvin };
+
+ if (output_units.temperature == FAHRENHEIT) {
+ deg = to_F(temperature);
+ unit = "F";
+ } else {
+ deg = to_C(temperature);
+ unit = "C";
+ }
+ plot_text(gc, &tro, sec, temperature.mkelvin, "%d %s", deg, unit);
+}
+
+static void plot_temperature_text(struct graphics_context *gc, struct plot_info *pi)
+{
+ int i;
+ int last = 0;
+ int last_temperature = 0, last_printed_temp = 0;
+
+ if (!setup_temperature_limits(gc, pi))
+ return;
+
+ for (i = 0; i < pi->nr; i++) {
+ int sec;
+ struct plot_data *entry = pi->entry+i;
+ int mkelvin = entry->temperature;
+
+ if (!mkelvin)
+ continue;
+ last_temperature = mkelvin;
+ sec = entry->sec;
+ if (sec < last + 300)
+ continue;
+ last = sec;
+ plot_single_temp_text(gc,sec,mkelvin);
+ last_printed_temp = mkelvin;
+ }
+ /* it would be nice to print the end temperature, if it's different */
+ if (last_temperature != last_printed_temp)
+ plot_single_temp_text(gc, last, last_temperature);
+}
+
+static void plot_temperature_profile(struct dive *dive, struct graphics_context *gc,
+ struct plot_info *pi)
+{
+ int i;
+ cairo_t *cr = gc->cr;
+ int last = 0;
+
+ if (!setup_temperature_limits(gc, pi))
+ return;
+
+ set_source_rgba(gc, 0.2, 0.2, 1.0, 0.8);