def plot_iv(self, th, fits, iv=Data()): # Plot the current data current_line = self.fig.host.errorbar(x=iv.v_mean, y=iv.i_mean, yerr=iv.i_error, fmt='r.', label='Current') # Label axis self.fig.host.set_xlabel("Voltage (V)") self.fig.host.set_ylabel("Current ($\mu$A)") # List of plotted lines lines = [current_line] # Tick size tkw = dict(size=4, width=1.5) self.fig.host.tick_params(axis='x', **tkw) # If plotting temperature and humidity lines: if th: # Overall average temperature and humidity temp_averages = iv.average_temp() hum_averages = iv.average_hum() # Plot temperature and humidity temp_line, = self.fig.temp.plot( iv.v_mean, iv.temperature, color='b', alpha=0.4, label='Temperature, $T_{Av}$ = %s$^\circ$C' % temp_averages[0]) hum_line, = self.fig.hum.plot(iv.v_mean, iv.humidity, color='g', alpha=0.4, label='Humidity, $H_{Av}$ = %s%%' % hum_averages[0]) # Colour axis self.fig.temp.yaxis.label.set_color(temp_line.get_color()) self.fig.hum.yaxis.label.set_color(hum_line.get_color()) # Uncomment to constrain axis range #self.fig.hum.set_ylim([30, 50]) #self.fig.temp.set_ylim([18, 22]) # Label axis self.fig.temp.set_ylabel("Temperature ($^\circ$C)") self.fig.hum.set_ylabel("Humidity (%)") self.fig.temp.tick_params(axis='y', colors=temp_line.get_color(), **tkw) self.fig.hum.tick_params(axis='y', colors=hum_line.get_color(), **tkw) # Add to list of lines lines.append(temp_line) lines.append(hum_line) # If finding the breakdown voltage: if fits: bd_voltage = Fitting.breakdown_voltage(iv)[0] bd_statement = Fitting.breakdown_voltage(iv)[1] #print(bd_statement) # Plot a vertical line at breakdown voltage if bd_voltage is not None: bd_line = self.fig.host.axvline( x=bd_voltage, color='r', linestyle='--', label='$V_{Breakdown}$ = %sV' % Fitting.round_sig(bd_voltage, 3)) lines.append(bd_line) else: no_bd_line, = self.fig.host.plot([], [], ' ', label=bd_statement) lines.append(no_bd_line) # Create legend and title self.fig.host.legend(lines, [l.get_label() for l in lines]) self.fig.suptitle(iv.name)