如何正确可视化 Prefuse (Java) 表?

发布于 2024-12-27 05:46:30 字数 711 浏览 0 评论 0原文

我想通过 Prefuse Java 在表中可视化有关汽车的一些数据。 使用了三种重要的数据对象:

  1. PIT(时间点)
  2. 值(包含 Double 形式的汽油消耗)
  3. 汽车(代表汽车的类)

所以首先我将它们放入这样的表中:

car1 | pit1 | value11
car1 | pit2 | value12
car1 | pit3 | value13
car2 | pit1 | value21
car2 | pit2 | value22
car2 | pit3 | value23
car3 | pit1 | value31
car3 | pit2 | value32
car3 | pit3 | value33

使用中的示例在 Prefuse 项目中,我能够创建一个表格的可视化,其中 x 轴标记有pit1、pit2 和pit3,y 轴以正确的顺序标记有不同的值。

但我已经尝试了几个小时,以某种方式在相应的点绘制小方块(例如 car1 的红色方块,其中pit1和value11“相遇”)。

我该怎么做?

PS:我还想知道如何通过以下方式改进y轴:

想象一下最低值为2.6,最高值为32.0。 现在,y 轴将从 2.6 开始,只标记每个值(无论实际差异如何,标签之间的间距相同),直到 32.0。 我更喜欢的是标签以 0.0(或 2.0)开始,然后使用 5 左右的步骤直到 35。

I want to visualize some data about cars in a table via Prefuse Java.
Three kinds of important data objects are used:

  1. PIT (Point in Time)
  2. Value (contains the consumption of gas as a Double)
  3. Car (the class that represents a Car)

So first I put them into a table like this:

car1 | pit1 | value11
car1 | pit2 | value12
car1 | pit3 | value13
car2 | pit1 | value21
car2 | pit2 | value22
car2 | pit3 | value23
car3 | pit1 | value31
car3 | pit2 | value32
car3 | pit3 | value33

Using the examples in the Prefuse project I was able to create a visualization of a table with the x-axis labeled with pit1, pit2 and pit3 and the y-axis with the different values in correct order.

But what I've tried for hours is to somehow draw little squares at the corresponding spots (like a red square for car1 where pit1 and value11 "meet").

How do I do this?

PS: I also would like to know how to improve the y-axis in the following way:

Imagine the lowest value is 2.6 and the highest is 32.0.
Right now the y-axis would start with 2.6 and just label every value (with the same space between the labels regardless of the actual difference) up to 32.0.
What I would prefer is that the labels would start with 0.0 (or 2.0) and then use steps of 5 or so till 35.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥有 2025-01-03 05:46:30

您希望以散点图形式可视化表格,其中 PIT 位于 x 轴,Value 位于 y 轴,Car 作为标记(= 矩形)的颜色。

如果我理解正确的话,您会看到轴标签,但没有标记。

您需要将 ColorAction 添加到操作列表中才能看到标记。例如:

ColorAction color = new ColorAction("data", VisualItem.STROKECOLOR,
                ColorLib.rgb(100, 100, 255));

或者使用 DataColorAction,它允许您根据汽车以不同颜色可视化标记:

ColorAction color = new DataColorAction("data", "Car", 
                Constants.NOMINAL, VisualItem.FILLCOLOR);

关于 y 轴:如果无法读取变量,prefuse 会绘制每个标签并忽略实际差异(这里:值)作为双精度。请检查它是否存储为DoubleString
如果你想从 0.0 开始,你可以设置一个范围模型:

y_axis.setRangeModel(new NumberRangeModel(0, 40, 0, 40)); 

PS:我已经写了一个 prefuse 散点图教程:http://www.ifs.tuwien.ac.at/~rind/w/doku.php/java/prefuse-scatterplot

You want to visualize your table in a scatter plot with PIT on the x-axis, Value on the y-axis, and Car as the color of the marks (= rectangles).

If I understood you correctly, you see the axis labels but no marks.

You need to add a ColorAction to your action list in order to see the marks. For example:

ColorAction color = new ColorAction("data", VisualItem.STROKECOLOR,
                ColorLib.rgb(100, 100, 255));

Or use a DataColorAction, which allows you to visualize marks in different color depending on Car:

ColorAction color = new DataColorAction("data", "Car", 
                Constants.NOMINAL, VisualItem.FILLCOLOR);

Regarding the y-axis: prefuse draws every label and ignores actual difference, if it cannot read the variable (here: Value) as a double. Please check if it is stored as Double or String.
If you want to start at 0.0 you you can set a range model:

y_axis.setRangeModel(new NumberRangeModel(0, 40, 0, 40)); 

PS: I have written a tutorial for prefuse scatter plots: http://www.ifs.tuwien.ac.at/~rind/w/doku.php/java/prefuse-scatterplot

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文