【问题标题】:how do I mark special data points in JChart2D?如何在 JChart2D 中标记特殊数据点?
【发布时间】:2011-09-08 12:04:50
【问题描述】:

在 JChart2D 中,可以用小圆圈或通过这些点绘制的线来绘制系列中的点。我需要将用户的注意力吸引到某些特定的点上。

我如何用实心圆圈或其他类型的符号标记偶尔出现的点。

提供的垂直条形图似乎将整个绘图更改为垂直条形图(在它出现的那一点,也“追溯”到旧点)。我不要那个。我只需要让一个点看起来特别,例如,X=5 处的点。

    Chart2D chart = new Chart2D();
    ITrace2D myTrace = new Trace2DLtd(100); 
    myTrace.setColor(Color.RED);
    myTrace.setTracePainter(new TracePainterDisc()); // circle; not filled

    chart.addTrace(myTrace);

    JFrame frame = new JFrame(Constants.graphTitle);
    frame.getContentPane().add(chart);

    frame.setSize(200, 200);
    frame.addWindowListener(
        new WindowAdapter(){
          public void windowClosing(WindowEvent e){
              System.exit(0);
          }
        }
      );
    frame.setVisible(true);

    List<Point> list = Helper.makeList();
    for (Point p: list)
    {
        if (p.x != 5)
            myTrace.addPoint(p.x, p.y);
        else
        {
            // MAKE THIS POINT LOOK DIFFERENT, BUT HOW?
            myTrace.addPoint(p.x, p.y);
        }
    }
  }
}

【问题讨论】:

    标签: plot


    【解决方案1】:

    将相关代码替换为:

    PointPainterDisc icon = new PointPainterDisc(); 
    icon.setDiscSize(20); // make it bigger than the others
    icon.setColorFill(Color.BLUE); // choose a color not used by the others
    TracePoint2D point = new TracePoint2D(p.x, p.y);
    point.addAdditionalPointPainter(icon);
    myTrace.addPoint(point);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-18
      • 2021-08-10
      • 1970-01-01
      • 2018-03-11
      • 2019-07-17
      • 2016-09-12
      • 2018-09-13
      相关资源
      最近更新 更多