第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在java的jfreechart中從范圍軸獲取后在域軸上設(shè)置刻度單位?

如何在java的jfreechart中從范圍軸獲取后在域軸上設(shè)置刻度單位?

我在Java有點(diǎn)新?,F(xiàn)在,我正在嘗試使用JFreeChart繪制XYPlot,其中域軸(X軸)和范圍軸(Y軸)包含相同的范圍。但不幸的是,滴答單位是不同的!出于這個(gè)原因,我嘗試使用NumberAxis根據(jù)范圍軸上的范圍和刻度單位在域軸上設(shè)置范圍和刻度單位。但差異仍然存在。我仍然無(wú)法找出為什么會(huì)發(fā)生這種情況。我正在附加此繪圖的代碼。此外,我正在附加問(wèn)題的屏幕截圖以及我真正想要的!請(qǐng)指導(dǎo)我在這里做錯(cuò)了什么...    XYSeriesCollection lineChartDataAD = new XYSeriesCollection();    XYSeries seriesAD = new XYSeries("Real Surface Heights", false, true);    for (int m = 0; m < pt.delayedy.length - 1; m++) {        seriesAD.add((double)pt.delayedy[m], (double)pt.delayedy[m+1]);    }    lineChartDataAD.addSeries(seriesAD);                   if (jRadioButton10.isSelected()) { //as it is       checkbox2.getState() == true        pt.xaxisAD = pt.yvar+" ("+pt.xvar+") ["+pt.yunit+"]";        pt.yaxisADsupport = String.format("%f", (pt.xspace*pt.delay));        //pt.yaxisAD = pt.yvar +" (i+"+pt.yaxisADsupport+")";        pt.yaxisAD = pt.yvar+" ("+pt.xvar+"+d) ["+pt.yunit+"]";        jLabel44.setText("(Delay (d) = "+pt.yaxisADsupport+" "+pt.xunit+")");    }    else if (jRadioButton11.isSelected()) { //as time series  checkbox1.getState() == true        //pt.yaxisAD = pt.yvar +" (i+"+pt.delay+")";        pt.xaxisAD = pt.yvar+" (i) ["+pt.yunit+"]";        pt.yaxisAD = pt.yvar +" (i+d) ["+pt.yunit+"]";        jLabel44.setText("(Delay (d) = "+pt.delay+")");    }    JFreeChart lineChartAD = ChartFactory.createXYLineChart("", pt.xaxisAD, pt.yaxisAD, (XYDataset) lineChartDataAD, PlotOrientation.VERTICAL, false, false, false);    XYPlot plotAD  = lineChartAD.getXYPlot();    NumberAxis D = (NumberAxis) plotAD.getDomainAxis();    NumberAxis R = (NumberAxis) plotAD.getRangeAxis();    D.setRange(R.getRange());    D.setTickUnit(R.getTickUnit());                    XYLineAndShapeRenderer rendererAD = new XYLineAndShapeRenderer();問(wèn)題||的屏幕截圖刻度單位不同所需結(jié)果||的屏幕截圖兩個(gè)軸上的刻度單位相同
查看完整描述

1 回答

?
有只小跳蛙

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊

最后,我有一個(gè)解決這個(gè)問(wèn)題的解決方法!而我還不知道這個(gè)問(wèn)題的確切解決方案。


而不是嘗試以下代碼行,


NumberAxis D = (NumberAxis) plotAD.getDomainAxis(); 

NumberAxis R = (NumberAxis) plotAD.getRangeAxis(); 

D.setRange(R.getRange()); 

D.setTickUnit(R.getTickUnit());

我嘗試了以下代碼行:


//getting the number axes from the plot


NumberAxis D = (NumberAxis) plotAD.getDomainAxis();

NumberAxis R = (NumberAxis) plotAD.getRangeAxis();


//creating custom tick units based on lower and upper bound


Double DT = (D.getUpperBound() - D.getLowerBound())/5;

DecimalFormat DF = new DecimalFormat("#.#");

DF.setRoundingMode(RoundingMode.FLOOR);

String DTS = DF.format(DT);

DT = Double.parseDouble(DTS);

D.setTickUnit(new NumberTickUnit(DT));

Double RT = (R.getUpperBound() - R.getLowerBound())/5;

String RTS = DF.format(RT);

RT = Double.parseDouble(RTS);

R.setTickUnit(new NumberTickUnit(RT));

它的工作原理!!!請(qǐng)參閱下面附帶的屏幕截圖,這就是我想要的,兩個(gè)軸上的相同刻度單位...

http://img1.sycdn.imooc.com//632c14bc0001d31605490573.jpg

下面還給出了這種繪圖的完整代碼(可能會(huì)增加一些代碼行,但我很高興它適用于任何情況,直到我得到這個(gè)問(wèn)題的確切解決方案):


//Creating XYseries based on an array (i.e., pt.delayedy)


XYSeriesCollection lineChartDataAD = new XYSeriesCollection();

XYSeries seriesAD = new XYSeries("Real Surface Heights", false, true);


for (int m = 0; m < pt.delayedy.length - 1; m++) {            

    seriesAD.add((double)pt.delayedy[m], (double)pt.delayedy[m+1]);

}


lineChartDataAD.addSeries(seriesAD);


//Customizing my axis labels (required for my purpose)


if (jRadioButton10.isSelected()) {

   pt.xaxisAD = pt.yvar+" ("+pt.xvar+") ["+pt.yunit+"]";

   pt.yaxisADsupport = String.format("%f", (pt.xspace*pt.delay));            

   pt.yaxisAD = pt.yvar+" ("+pt.xvar+"+d) ["+pt.yunit+"]";      

}

else if (jRadioButton11.isSelected()) {            

   pt.xaxisAD = pt.yvar+" (i) ["+pt.yunit+"]";

   pt.yaxisAD = pt.yvar +" (i+d) ["+pt.yunit+"]";

   jLabel44.setText("(Delay (d) = "+pt.delay+")");

}


//Creating a JFreechart with my labels and series


JFreeChart lineChartAD = ChartFactory.createXYLineChart("", pt.xaxisAD, pt.yaxisAD, (XYDataset) lineChartDataAD, PlotOrientation.VERTICAL, false, false, false);


//Getting the chart plot


XYPlot plotAD  = lineChartAD.getXYPlot();


//Creating the renderer for the chart


XYLineAndShapeRenderer rendererAD = new XYLineAndShapeRenderer();

rendererAD.setSeriesPaint(0, Color.BLACK);

double sizeAD = 0;

double deltaAD = sizeAD / 2.0;

Shape shapeAD = new Rectangle2D.Double(-deltaAD, -deltaAD, sizeAD, sizeAD);

rendererAD.setSeriesShape(0, shapeAD);

rendererAD.setSeriesStroke(0, new BasicStroke(1.0f));


//Customizing the font of the axes labels


Font F1AD = new Font ("Times New Roman", Font.PLAIN, 14);        

plotAD.getDomainAxis().setLabelFont(F1AD);

plotAD.getRangeAxis().setLabelFont(F1AD);


//The below lines are for exact same x-scaling and y-scaling in plot


NumberAxis D = (NumberAxis) plotAD.getDomainAxis();

NumberAxis R = (NumberAxis) plotAD.getRangeAxis();

D.setAutoRangeIncludesZero(false);

R.setAutoRangeIncludesZero(false);

Double DT = (D.getUpperBound() - D.getLowerBound())/5;

DecimalFormat DF = new DecimalFormat("#.#");

DF.setRoundingMode(RoundingMode.FLOOR);

String DTS = DF.format(DT);

DT = Double.parseDouble(DTS);

D.setTickUnit(new NumberTickUnit(DT));

Double RT = (R.getUpperBound() - R.getLowerBound())/5;

String RTS = DF.format(RT);

RT = Double.parseDouble(RTS);

R.setTickUnit(new NumberTickUnit(RT));


//Plot customization


plotAD.setOutlinePaint(Color.BLACK);

plotAD.setOutlineStroke(new BasicStroke(0.5f));

plotAD.setRenderer(rendererAD);

plotAD.setBackgroundPaint(Color.WHITE);

plotAD.setRangeGridlinesVisible(true);

plotAD.setRangeGridlinePaint(Color.GRAY);

plotAD.setDomainGridlinesVisible(true);

plotAD.setDomainGridlinePaint(Color.GRAY);


//Creating ChartPanel


ChartPanel linePanelAD = new ChartPanel(lineChartAD, true, true, false, false, true);

linePanelAD.setMouseZoomable(false);


//Adding the ChartPanel to the JPanel 


panelChartRMA4D.removeAll();

panelChartRMA4D.add(linePanelAD, BorderLayout.CENTER);

panelChartRMA4D.setVisible(true);

panelChartRMA4D.setBorder(new LineBorder (Color.BLACK));

panelChartRMA4D.validate();


查看完整回答
反對(duì) 回復(fù) 2022-09-22
  • 1 回答
  • 0 關(guān)注
  • 166 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)