/** * Makes a plot showing overlaid individual normalized count for every word in WORDS from * STARTYEAR to ENDYEAR using NGM as a data source. */ public static void plotAllWords(NGramMap ngm, String[] words, int startYear, int endYear) { Chart chart = new ChartBuilder().width(800).height(600).xAxisTitle("years").yAxisTitle("data").build(); for (String word : words) { TimeSeries bundle = ngm.weightHistory(word, startYear, endYear); chart.addSeries(word, bundle.years(), bundle.data()); } new SwingWrapper(chart).displayChart(); }
/** * Creates a plot of the TimeSeries TS. Labels the graph with the given TITLE, XLABEL, YLABEL, and * LEGEND. */ public static void plotTS( TimeSeries ts, String title, String xlabel, String ylabel, String legend) { Collection years = ts.years(); Collection counts = ts.data(); // Create Chart Chart chart = QuickChart.getChart(title, ylabel, xlabel, legend, years, counts); // Show it new SwingWrapper(chart).displayChart(); }
/** * Creates overlaid category weight plots for each category label in CATEGORYLABELS from STARTYEAR * to ENDYEAR using NGM and WN as data sources. */ public static void plotCategoryWeights( NGramMap ngm, WordNet wn, String[] categoryLabels, int startYear, int endYear) { Chart chart = new ChartBuilder().width(800).height(600).xAxisTitle("years").yAxisTitle("data").build(); for (String categoryLabel : categoryLabels) { Set words = wn.hyponyms(categoryLabel); TimeSeries bundle = ngm.summedWeightHistory(words, startYear, endYear); chart.addSeries(categoryLabel, bundle.years(), bundle.data()); } new SwingWrapper(chart).displayChart(); }