Calculate beta distribution and drawing (2), calculate beta distribution drawing

Source: Internet
Author: User

Calculate beta distribution and drawing (2), calculate beta distribution drawing

Import java. awt. font; import java. awt. gridLayout; import java. io. bufferedReader; import java. io. fileReader; import java. io. IOException; import javax. swing. JFrame; import org. jfree. chart. chartFactory; import org. jfree. chart. chartPanel; import org. jfree. chart. JFreeChart; import org. jfree. chart. axis. numberAxis; import org. jfree. chart. plot. categoryPlot; import org. jfree. chart. plot. plotOrientation; import org. jfree. Data. category. categoryDataset; import org. jfree. data. category. defaultCategoryDataset; import zxy. nlp. lda. conf. pathConfig; public class plotbetadis {ChartPanel frame1; public plotbetadis () throws IOException {defacategorydataset dataset = (DefaultCategoryDataset) createDataset (); JFreeChart chart = ChartFactory. createLineChart ("", "date", "topic intensity/%", dataset, PlotOrientation. VERTICAL, true, True, true); CategoryPlot plot = chart. getCategoryPlot (); NumberAxis numberaxis = (NumberAxis) plot. getRangeAxis (); numberaxis. setStandardTickUnits (NumberAxis. createIntegerTickUnits (); numberaxis. setLabelFont (new Font ("", Font. BOLD, 14); // horizontal bottom heading numberaxis. setTickLabelFont (new Font ("", Font. BOLD, 12); // vertical title frame1 = new ChartPanel (chart, true); chart. getLegend (). setItemFont (new Font ("", Font. BOL D, 15); chart. getTitle (). setFont (new Font ("", Font. BOLD, 20); // set the title Font} private static CategoryDataset createDataset () throws IOException {defacategcategorydataset = new DefaultCategoryDataset (); int lnum = 2; String resPath = PathConfig. ldaResultsPath; String modelName = "ldatimes"; FileReader fr = new FileReader (filename); double [] [] nodes = new double [lnum] []; String [] lines; // System. out. println ("read the file content in the unit of action, one read for the whole row at a time:"); BufferedReader br = new BufferedReader (fr); String line = null; int x = 0; // read a row at a time until null is the end of the file while (line = br. readLine ())! = Null & x <lnum) {// display the row number // System. out. println ("line" + lnum + ":" + line); lines = line. split ("\ t"); // for (int I = 0; I <lines. length; I ++) {// System. out. println ("one-dimensional:" + lines [I] + ""); //} nodes [x] = new double [lines. length]; for (int y = 0; y <lines. length; y ++) {nodes [x] [y] = Double. parseDouble (lines [y]); String s = String. valueOf (y + 4)/4); String t = String. valueOf (x); defaultcategorydataset. addValue (nodes [x] [y], "top" + t, s) ;}x ++; // lines = null ;}br. close (); return defadefacategorydataset;} public ChartPanel getChartPanel () {return frame1;} public static void main (String args []) throws IOException {JFrame frame = new JFrame ("Data Statistics"); frame. setLayout (new GridLayout (2, 2, 5); frame. add (new plotbetadis (). getChartPanel (); // Add a line chart frame. setBounds (50, 50,600,600); frame. setVisible (true );}}

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.