Plotting in Jaida with different styles
Code: "jaida_PlotWithStyles.java". Programming language: Java DMelt Version 1. Last modified: 05/19/2016. License: Pro
https://datamelt.org/code/cache/jaida_PlotWithStyles_8740.java
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



import hep.aida.*;
import java.util.Random;

public class jaida_PlotWithStyles {

    public static void main(String[] argv) {
        IAnalysisFactory af = IAnalysisFactory.create();
        ITree tree = af.createTreeFactory().create();
        IHistogramFactory hf = af.createHistogramFactory(tree);
        
        IHistogram1D h1 = hf.createHistogram1D("h1",100,-5,5);
        IHistogram1D h2 = hf.createHistogram1D("h2",100,-5,5);
        
        Random r = new Random();
        
        for ( int i = 0; i<10000; i++ ) {
            h1.fill(r.nextGaussian());
            h2.fill(r.nextGaussian());
        }
        
        IPlotterFactory plotterFactory = af.createPlotterFactory();
        IPlotter plotter = plotterFactory.create("Plotting with Styles");
        
        //This are the default styles for the region
        IPlotterStyle regionStyle = plotter.region(0).style();
        regionStyle.dataStyle().lineStyle().setParameter("color","black");
        regionStyle.xAxisStyle().setLabel("E/m");
        regionStyle.yAxisStyle().setLabel("# Evt");
        
        regionStyle.titleStyle().textStyle().setFontSize(30);
        regionStyle.titleStyle().textStyle().setColor("orange");
        
        regionStyle.xAxisStyle().labelStyle().setFontSize(24);
        regionStyle.xAxisStyle().labelStyle().setItalic(true);
        regionStyle.xAxisStyle().labelStyle().setColor("black");
        regionStyle.xAxisStyle().tickLabelStyle().setFontSize(14);
        regionStyle.xAxisStyle().tickLabelStyle().setBold(true);
        regionStyle.xAxisStyle().tickLabelStyle().setColor("blue");
        
        regionStyle.yAxisStyle().labelStyle().setFontSize(24);
        regionStyle.yAxisStyle().labelStyle().setItalic(true);
        regionStyle.yAxisStyle().labelStyle().setColor("brown");
        regionStyle.yAxisStyle().tickLabelStyle().setFontSize(14);
        regionStyle.yAxisStyle().tickLabelStyle().setBold(true);
        regionStyle.yAxisStyle().tickLabelStyle().setColor("green");
        
        //This styles overwrite some of the region styles
        IPlotterStyle style = plotterFactory.createPlotterStyle();
        style.dataStyle().markerStyle().setParameter("size","12");
        style.dataStyle().markerStyle().setParameter("shape","3");
        style.dataStyle().markerStyle().setParameter("color","blue");
        
        plotter.region(0).plot(h1);
        plotter.region(0).plot(h2,style);
        
        plotter.show();
    }
}


Ads help maintain this website.