有关如何为X轴和Y轴设置范围的任何建议.
我的"X轴"范围是"0.00到1.00",相差"0.05".我的意思是0.00 0.05 0.10 0.15 ..... 0.90 0.95 1.00
我的"Y轴"范围从"0.0到1.0",差异为"0.1".我的意思是0.0 0.1 0.2 0.3 0.4 ......... 0.9 1.0
我尝试过这样做,但它没有反映在图表上; 我不知道如何应用它 ChartFactory.createScatterPlot().
final NumberAxis domainAxis = new NumberAxis("X-Axis");
domainAxis.setRange(0.00,1.00);
domainAxis.setTickUnit(new NumberTickUnit(0.1));
final NumberAxis rangeAxis = new NumberAxis("Y-Axis");
rangeAxis.setRange(0.0,1.0);
rangeAxis.setTickUnit(new NumberTickUnit(0.05));
public JPanel createDemoPanel() {
XYDataset dataset1 = samplexydataset2();
JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo",
"X", "Y",dataset1, PlotOrientation.VERTICAL, true, true, false);
}
Run Code Online (Sandbox Code Playgroud)
对此有任何帮助都会很棒.
我正在使用JFreeChart XYPLot绘制具有不同标签的XYData集.我为不同的标签创建了不同的XYSeries对象,这样我就可以为不同的标签设置不同的颜色.现在我需要更改每个XYDataSeries中特定点(测试数据)的形状,如下所示
.在上面的绘图中,有两种不同的XYSeries,蓝色和红色.在这两个中,我需要将某些点(测试数据)的形状更改为X而不是圆形.是否有可能在JFreeChart. 这篇文章解释了如何为整个数据集做到这一点,但我想只改变特定点
下面是我到目前为止编写的代码
public static Map<String, XYSeries> createXYSeries(Data[] dataSet){
Map<String,XYSeries> xySeries = new HashMap<String, XYSeries>();
for(Data data : dataSet){
if(xySeries.get(data.actualLabel) == null){
xySeries.put(data.actualLabel, new XYSeries(data.actualLabel));
}
xySeries.get(data.actualLabel).add(data.dimensionValues[0],data.dimensionValues[1]);
}
return xySeries;
}
public XYDataset createXYSeriesCollection(Map<String, XYSeries> plottingDataSet) {
XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
for (String key : plottingDataSet.keySet()) {
xySeriesCollection.addSeries(plottingDataSet.get(key));
}
return xySeriesCollection;
}
private ChartPanel createPlottingPanel(String title,
Map<String, XYSeries> plottingDataSet) {
JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "X", "Y",
createSampleData(plottingDataSet), PlotOrientation.VERTICAL,
true, true, false);
XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); …Run Code Online (Sandbox Code Playgroud) 在此问题的选定答案中,我想更改标记大小,我该怎么做?
这是我使用Java的第一个月,所以我提前为我的愚蠢问题道歉.我正在尝试使用Jfreechart制作一个简单的程序.我想在散点图上显示我的2D数组.这是代码:
package myappthatusesjfreechart;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.general.DefaultPieDataset;
public class MyAppThatUsesJFreeChart {
public static void main(String[] args) {
// create a dataset...
int[][] a2 = new int[10][5];
// print array in rectangular form
for (int r = 0; r < a2.length; r++) {
for (int c = 0; c < a2[r].length; c++) {
System.out.print(" " + a2[r][c]);
}
System.out.println("");
}
// create a chart...
JFreeChart chart = ChartFactory.createScatterPlot(
"Scatter Plot", // chart title
"X", // …Run Code Online (Sandbox Code Playgroud) 我需要在JFreechart中的Timeseries上获得A钻石形状,但我无法做到.有人可以指导一下代码应该添加到下面的代码中以实现Diamond形状点以及如何更改线条的颜色?
(该程序使用rs和stmt以及从DB派生的其他东西,并在其他地方定义.该程序现在正常工作,唯一的问题是它看起来非常无聊.)
TimeSeries s1 = new TimeSeries("Technology", Day.class);
TimeSeries s2 = new TimeSeries("Entertainment", Day.class);
TimeSeries s3 = new TimeSeries("Soap", Day.class);
TimeSeries s4 = new TimeSeries("Music", Day.class);
TimeSeries s5 = new TimeSeries("Native", Day.class);
TimeSeries s6 = new TimeSeries("Speciality", Day.class);
TimeSeries s7 = new TimeSeries("Science", Day.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date plotdate;
if (!(combo_individualid.getModel().getSize() == 0)) {
String sql = ""
+ "SELECT * "
+ "FROM `customerbasetag` "
+ "WHERE `individual_idindividual` =? ";
try {
stmt = conn.prepareStatement(sql);
stmt.setString(1, combo_individualid.getSelectedItem().toString()); …Run Code Online (Sandbox Code Playgroud) 我使用JFreeChart绘制了标准的正态分布:
NormalDistributionFunction2D normalDistributionFunction2D = new NormalDistributionFunction2D(0.5, 0.15);
XYDataset dataset = DatasetUtilities.sampleFunction2D(normalDistributionFunction2D, 0.0, 1.0, 1000, "Normal");
JFreeChart chart = ChartFactory.createXYLineChart("MyTitle --, "", "", xySeriesCollection, PlotOrientation.VERTICAL, false, false, false);
Run Code Online (Sandbox Code Playgroud)

最重要的是,我想在给定点放置一个圆圈.我在计算圆的[x,y]坐标时没有问题,但我不确定如何将它添加到图表中.任何帮助赞赏.我想要实现的MS Paint爆破如下.
