Nebula is an Eclipse Project that allows you to use hundreds of cool widgets to make your application really awesome.

XYGraph is one of them and you can use it to plot a graph with plenty of options. Let’s see how to do that.

In Eclipse menu select Help, Install New Software…, put the following Update Site in the Work with field


then expand Nebula Release Individual Widgets node
and select Nebula Visualization Widgets, finish the installation and let Eclipse restart.

Now you can create a new application with File, New, Project, Plug-in Development, Plug-in Project, Next.

Give the project a name, e.g. it.rcpvision.nebula.xygraph, Next, select

  • Generate an activator, …
  • This plug-in will make contributions to the UI
  • Would you like to create a rich client application: Yes

Next, then select Eclipse 4 RCP application template, Next, select Create sample content …, Finish
(confirm opening Plug-in Development perspective is just a matter of taste, let’s say yes).


Now navigate and open /it.rcpvision.nebula.xygraph/src/it/rcpvision/nebula/xygraph/parts/

remove the following parts

private Text txtInput;
private TableViewer tableViewer;

private MPart part;

txtInput = new Text(parent, SWT.BORDER);
txtInput.setMessage("Enter text to mark part as dirty");
txtInput.addModifyListener(e -> part.setDirty(true));
txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

tableViewer = new TableViewer(parent);

tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
public void save() {

private List<String> createInitialDataModel() {
    return Arrays.asList("Sample item 1", "Sample item 2", "Sample item 3", "Sample item 4", "Sample item 5");

Press Ctrl-Shift-O to remove unused imports, Save and you’ll get an empty Part.

You can test it by selecting it.rcpvision.nebula.xygraph.product, right click, Run As, Eclipse Application: your empty application will pop-up. Now close it.


Ok, time to add the right dependencies: open (double-click) MANIFEST.MF, Dependencies tab, Add

  • org.eclipse.draw2d
  • org.eclipse.nebula.visualization.xygraph

in the Required Plug-ins, Save.

Then open it.rcpvision.nebula.xygraph.product, Contents tab, Add the same two plug-ins, Save

Then go again in and, after line

parent.setLayout(new GridLayout(1, false));

in createComposite() method, add the following lines

Canvas canvas = new Canvas(parent, SWT.NONE);
canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
LightweightSystem lws = new LightweightSystem(canvas);
XYGraph xyGraph = new XYGraph();
ToolbarArmedXYGraph toolbarArmedXYGraph = new ToolbarArmedXYGraph(xyGraph);
CircularBufferDataProvider traceDataProviderTraining = new CircularBufferDataProvider(false);
Trace traceTraining = new Trace("Trace legenda", xyGraph.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(),traceDataProviderTraining);

xyGraph.setTitle("Sigmoid function");
xyGraph.getPrimaryXAxis().setTitle("X axis");
xyGraph.getPrimaryYAxis().setTitle("Y axis");

//Plot our xy function
for (int x = -20; x < 20; x++) {
    double y = 1.0 / (1.0 + Math.exp(-x));
    traceDataProviderTraining.addSample(new Sample(x,y));

In the end we are ready to relaunch our application (right-click it.rcpvision.nebula.xygraph.productRun As, Eclipse Application) and see (and play with) our new graph.