Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

How do I label minor ticks in a JFreeChart in Java?

I have a problem where my LogarithmicAxis is not showing values at minor ticks. Is there a way to show these values or specify the values by hand? I would like to have more values on my y-axis. Any idea?

My Chart

public void Woehler_zeichnen(JTable table, JPanel content) {
    
    XYPlot plot = new XYPlot();

    XYDataset scatterPlotDataset = getMesspunkte(table); 
    plot.setDataset(0, scatterPlotDataset);
    plot.setRenderer(0, new XYLineAndShapeRenderer(false, true));
   
    LogAxis xax = new LogAxis("Schwingspielzahl n");
    LogarithmicAxis yax = new LogarithmicAxis("Spannung [MPa]");
    xax.setBase(10);
    
    //yax.setBase(10);
    //yax.setTickUnit(new NumberTickUnit(1.0, NumberFormat.getInstance(), 9));
    //yax.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yax.setTickMarkInsideLength(2f);
    yax.setTickMarkOutsideLength(4f);
    yax.setTickMarkPaint(Color.GREEN);
    yax.setTickMarkStroke(new BasicStroke(2f));
    yax.setMinorTickMarksVisible(true);
    
    plot.setDomainAxis(0, xax); //X-Achse
    plot.setRangeAxis(0, yax); //Y-Achse
   
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);

    XYDataset functionDataset = getAusgleichsgerade();
    plot.setDataset(1, functionDataset);
    plot.setRenderer(1, new XYLineAndShapeRenderer(true, false));

    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 0);
    
    JFreeChart chart = new JFreeChart("W?hlerlinie",JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    ChartPanel chartPanel = new ChartPanel(null);
    chartPanel.setChart(chart);
    if (woehler_ausgegeben == false) {
        content.add(chartPanel);
        woehler_ausgegeben = true;
    }        
    content.revalidate();
    }
question from:https://stackoverflow.com/questions/65602914/how-do-i-label-minor-ticks-in-a-jfreechart-in-java

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...