Пример #1
0
    def _create_plot(i, name, data, counter_two, display_plot=True):
        # Step the color on all subplots no just on plots
        # within the same axis/subplot
        # this is to match the qcodes-pyqtplot behaviour.
        title = "{} #{:03d}".format(CURRENT_EXPERIMENT["sample_name"],
                                    data.location_provider.counter)
        rasterized_note = " rasterized plot full data available in datafile"
        color = 'C' + str(counter_two)
        counter_two += 1
        plot = MatPlot()
        if issubclass(
                i.__class__,
                MultiChannelInstrumentParameter) or i._instrument is None:
            inst_meas_name = name
        else:
            inst_meas_name = "{}_{}".format(i._instrument.name, name)
        inst_meas_data = getattr(data, inst_meas_name)
        try:
            inst_meas_data = getattr(data, inst_meas_name)
        except AttributeError:
            inst_meas_name = "{}{}_0_0".format(i._instrument.name, name)
            inst_meas_data = getattr(data, inst_meas_name)
        inst_meta_data = __get_plot_type(inst_meas_data, plot)
        if 'z' in inst_meta_data:
            xlen, ylen = inst_meta_data['z'].shape
            rasterized = xlen * ylen > 5000
            po = plot.add(inst_meas_data, rasterized=rasterized)

            auto_color_scale_from_config(po.colorbar, auto_color_scale,
                                         inst_meta_data['z'],
                                         cutoff_percentile)
        else:
            rasterized = False
            plot.add(inst_meas_data, color=color)
            plot.subplots[0].grid()
        if rasterized:
            plot.subplots[0].set_title(title + rasterized_note)
        else:
            plot.subplots[0].set_title(title)
        title_list = plot.get_default_title().split(sep)
        title_list.insert(-1, CURRENT_EXPERIMENT['pdf_subfolder'])
        title = sep.join(title_list)
        plot.rescale_axis()
        plot.tight_layout()
        plot.save("{}_{:03d}.pdf".format(title, counter_two))
        if display_plot:
            plot.fig.canvas.draw()
            plt.show()
        else:
            plt.close(plot.fig)
Пример #2
0
def plot_dataset(dataset: DataSet, scanjob, save=True) -> None:
    """ Plot a dataset to matplotlib figure window

    Args:
        dataset: DataSet to be plotted
        scanjob: scanjob of the measurement
        save: Select if you want to save the plots

    """

    parameter_names = [
        name for name in dataset.arrays.keys()
        if not dataset.arrays[name].is_setpoint
    ]
    default_array = dataset.default_parameter_array()

    # Path for saving
    base_loc = dataset.default_io.base_location
    folder = '\\' + dataset.location + '\\'
    label = str(scanjob.get('dataset_label'))
    path = base_loc + folder + label

    # 2D plots
    if len(default_array.shape) >= 2:
        for idx, parameter_name in enumerate(parameter_names):
            plot_handle = MatPlot(dataset.arrays[parameter_name], num=idx)
            plot_handle.rescale_axis()
            if save == True:
                plt.savefig(path + str(idx) + '.png')

    # 1D plots
    else:
        for idx, parameter_name in enumerate(parameter_names):
            plot_handle = MatPlot(dataset.arrays[parameter_name], num=idx)
            plot_handle.rescale_axis()
            if save == True:
                plt.savefig(path + str(idx) + '.png')