def add_experimental_plot(self, project, undolist=None):

        if undolist is None:
            undolist = project.journal

        ul = UndoList().describe("Experimental Plot")

        ds = Dataset()
        ds.key = pdict.unique_key(project.datasets, "exp_ds")
        ds.data = Table(ncols=2, nrows=5)
        ds.data[0] = [1,2,3,4,5]
        ds.data[1] = [1,4,9,16,25]

        ds2 = Dataset()
        ds2.key = pdict.unique_key(project.datasets, "exp_ds2")
        ds2.data = Table(ncols=2, nrows=4)
        ds2.data[0] = [10,17,3,8]
        ds2.data[1] = [1,89,48,1]

        plot = Plot()
        plot.key = pdict.unique_key(project.plots, "exp_plot")
        layer1 = Layer(type="line2d",
                       lines=[Line(source=ds,cx=0,cy=1),
                              Line(source=ds2,cx=0,cy=1)],
                       x=0.0, y=0.0, width=1.0, height=0.5)
        layer2 = Layer(type="line2d",
                       lines=[Line(source=ds2,cx=0,cy=1)],
                       x=0.0, y=0.5, width=1.0, height=0.5)
        plot.layers = [layer1, layer2]

        project.add_datasets([ds,ds2], undolist=ul)
        project.add_plot(plot, undolist=ul)
        undolist.append(ul)
    def new_dataset(self, key='dataset', undolist=None):
        """
        Add a new Dataset object to the Project.

        The `data` field contains a nearly empty numarray (1 row, 2
        columns, all zero).

        If no key is given, then one is created.  If the key already
        exists, then the method assures that it is unique within the
        Project.

        Returns newly created Dataset.
        """
        if undolist is None:
            undolist = self.journal
        
        key = pdict.unique_key(self.datasets, key)
        ds = Dataset()
        pdict.setitem(self.datasets, key, ds)
        ds.data = Table(nrows=1,ncols=2)
        ds.data.column(0).designation = 'X'
        ds.data.column(1).designation = 'Y'        
        self.sig_emit("notify::datasets")

        ui = UndoInfo(self.remove_objects, [ds], False)
        ui.describe("Create new Dataset '%s'" % key)
        undolist.append(ui)
        
        return ds
    def add_experimental_plot(self, project, undolist=None):

        if undolist is None:
            undolist = project.journal

        ul = UndoList().describe("Experimental Plot")

        ds = Dataset()
        ds.key = pdict.unique_key(project.datasets, "exp_ds")
        ds.data = Table(colcount=2, rowcount=5)
        ds.data[0] = [1,2,3,4,5]
        ds.data[1] = [1,4,9,16,25]

        ds2 = Dataset()
        ds2.key = pdict.unique_key(project.datasets, "exp_ds2")
        ds2.data = Table(colcount=2, rowcount=4)
        ds2.data[0] = [10,17,3,8]
        ds2.data[1] = [1,89,48,1]

        ulist.append( project.datasets, ds, undolist=ul )
        ulist.append( project.datasets, ds2, undolist=ul )                

        plot = Plot()
        plot.key = pdict.unique_key(project.plots, "exp_plot")
        layer1 = Layer(type="line2d",
                       lines=[Line(source=ds,cx=0,cy=1), Line(source=ds2)],
                       x=0.0, y=0.0, width=1.0, height=0.5)
        layer2 = Layer(type="line2d",
                       lines=[Line(source=ds2,cx=0,cy=1)],
                       x=0.0, y=0.5, width=1.0, height=0.5)
        plot.layers = [layer1, layer2]
#        plot.layers.arrange(rowcount=1, colcount=2)
        
        ulist.append( project.plots, plot, undolist=ul )

        uwrap.emit_last(project.datasets, "changed")
        undolist.append(ul)
def demo_zno():

    ds = Dataset(key="ZnO-10-Abs1")
    ds.data = read_table_from_file("../../../Examples/Data/zn10abs1.abs", "ASCII", delimiter="\t")

    tbl = ds.data
    tbl.column(0).set_values("key", "Wavelength", "label", "Wavelength (nm)")
    tbl.column(1).set_values(key="Absorption", designation="Y", label="Optical Absorption (arb. units)")

    layer = Layer(
        type="line2d",
        lines=[Line(source=ds)],
        axes={"x": Axis(label="Wavelength [nm]"), "y": Axis(label="Absorption [a.u.]")},
    )

    pl = Plot(label=u"Optical Absorption of ZnO Quantum Dots", layers=[layer], key=ds.key)

    spj = Project(plots=[pl], datasets=[ds])

    save_project(spj, "zno.spj")