示例#1
0
 def plot_cv(self, th, fits, cv=Data()):
     #print('amw_3')
     # Plot capacitance data
     capacitance_line = self.fig.host.errorbar(
         x=cv.v_mean,
         y=cv.inverse_c_squared,
         yerr=cv.inverse_c_squared_error,
         fmt='r.',
         label='Capacitance')
     # Label axis
     self.fig.host.set_xlabel("Voltage (V)")
     self.fig.host.set_ylabel("$1/C^2$ ($1/pF^2$)")
     # List of plotted lines
     lines = [capacitance_line]
     # Tick size and y axis limit
     tkw = dict(size=4, width=1.5)
     self.fig.host.tick_params(axis='x', **tkw)
     self.fig.host.set_ylim([0, max(cv.inverse_c_squared) * 1.1])
     # If plotting temperature and humidity:
     if th:
         # Overall average temperature and humidity
         temp_averages = cv.average_temp()
         hum_averages = cv.average_hum()
         # Plot temperature and humidity
         temp_line, = self.fig.temp.plot(
             cv.v_mean,
             cv.temperature,
             color='b',
             alpha=0.4,
             label='Temperature, $T_{Av}$ = %s$^\circ$C' % temp_averages[0])
         hum_line, = self.fig.hum.plot(cv.v_mean,
                                       cv.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 and tick parameters
         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 depletion voltage
     if fits:
         # Get data
         fit_data = Fitting.cv_fits(cv)
         # Plot two linear lines
         self.fig.host.plot(cv.v_mean, fit_data[0], 'r')
         self.fig.host.plot(cv.v_mean, fit_data[1], 'r')
         # Plot line at full depletion
         full_depletion = self.fig.host.axvline(
             x=fit_data[2],
             linestyle='--',
             color='r',
             label='$V_{Full \: Depletion}$ = %s $\pm$ %sV' %
             (fit_data[2], fit_data[3]))
         # Add to list of lines
         lines.append(full_depletion)
     # Create legend and title
     self.fig.host.legend(lines, [l.get_label() for l in lines])
     self.fig.suptitle(cv.name)