如何按添加顺序绘制X,Y坐标?

编程入门 行业动态 更新时间:2024-10-12 14:26:26
本文介绍了如何按添加顺序绘制X,Y坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想按输入的顺序将X和Y坐标连接成一个圆.

I want to connect X and Y coordinates by order which I inputed to make a circle .

我找到了一个用Java绘制X,Y坐标的程序. 然后我添加了我的圆数据,但是程序连接的最近的X,Y坐标未排序X,Y.

I found a program that draw X,Y coordinates in Java . Then I added my data of circle but program connected nearest X,Y coordinates not ordered X,Y .

public Graph(final String title) { super(title); final XYSeries series = new XYSeries("Random Data"); series.add(2.000 , 0); series.add(0 , 2.000); series.add(-2.000 , 0); series.add(0 , -2.000); final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart( "XY Series Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false );

我期望结果以正方形图表示.

I expected results as square diagram .

推荐答案

XYSeries API指定,

The XYSeries API specifies,

默认情况下,系列中的项目将按x值升序排列,并且允许重复使用x值.

By default, items in the series will be sorted into ascending order by x-value, and duplicate x-values are permitted.

您可以使用适当的构造函数来克服它,建议此处:

You can defeat this with the appropriate constructor, suggested here:

final XYSeries series = new XYSeries("Random Data", false);

在下图中,我添加了一个额外的数据点以关闭该图:

In the illustration below, I've added an extra data point to close the figure:

对于任意形状,也请考虑一个XYShapeAnnotation,请参见此处.

For arbitrary shapes, also consider an XYShapeAnnotation, seen here.

更多推荐

如何按添加顺序绘制X,Y坐标?

本文发布于:2023-11-22 01:46:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615494.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:坐标   顺序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!