生成具有多个(多组多组)X 轴数据集的图表

发布于 2024-08-01 18:20:01 字数 589 浏览 10 评论 0原文

我正在寻找一种方法来生成X轴上具有多组数据的图表,每组数据又分为多组多组。 我基本上想采用 此图表 并将类似的图表与其并排放置。 我正在尝试绘制多个服务器上具有不同配置 (0-1) 的相同作业 (0-3) 的持续时间(Y 轴)图(每个组具有相同的 8 个作业)。 希望下图能够说明我想要完成的任务(较小的分组由管道分隔,较大的分组由双管道分隔):

|| 0 1 | 0 1 | 0 1 | 0 1 || 0 1 | 0 1 | 0 1 | 0 1 || 0 1 | 0 1 | 0 1 | 0 1 ||
|| 0   | 1   | 2   | 3   || 0   | 1   | 2   | 3   || 0   | 1   | 2   | 3   ||
|| Server 1              || Server 2              || Server 3              ||

这可以使用 GD::Graph Perl 模块或 matplotlib Python 模块吗? 我找不到关于这个主题的示例或文档。

I am looking for a way to generate a graph with multiple sets of data on the X-axis, each of which is divided into multiple sets of multiple sets. I basically want to take this graph and place similar graphs side by side with it. I am trying to graph the build a graph of the duration (Y-axis) of the same jobs (0-3) with different configurations (0-1) on multiple servers (each group with the same 8 jobs). Hopefully the following diagram will illustrate what I am trying to accomplish (smaller groupings are separated by pipes, larger groupings by double pipes):

|| 0 1 | 0 1 | 0 1 | 0 1 || 0 1 | 0 1 | 0 1 | 0 1 || 0 1 | 0 1 | 0 1 | 0 1 ||
|| 0   | 1   | 2   | 3   || 0   | 1   | 2   | 3   || 0   | 1   | 2   | 3   ||
|| Server 1              || Server 2              || Server 3              ||

Is this possible with either the GD::Graph Perl module or the matplotlib Python module? I can't find examples or documentation on this subject for either.

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

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

发布评论

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

评论(3

黯淡〆 2024-08-08 18:20:01

这里有一些 Python 代码,可以生成您正在寻找的内容。 (该示例使用 3 个配置而不是 2 个配置来确保代码相当通用。)

import matplotlib.pyplot as plt
import random

nconfigs, njobs, nservers = 3, 4, 4

width = .9/(nconfigs*njobs)  
job_colors = [(0,0,1), (0,1,0), (1,0,0), (1,0,1)]

def dim(color, fraction=.5):
    return tuple([fraction*channel for channel in color])

plt.figure()
x = 0
for iserver in range(nservers):
    for ijob in range(njobs):
        for iconfig in range(nconfigs):
            color = dim(job_colors[ijob], (iconfig+2.)/(nconfigs+1))
            plt.bar(x, 1.+random.random(), width, color=color)
            x += width
    x += .1

plt.show()

此代码可能相当透明。 奇怪的术语 (iconfig+2.)/(nconfigs+1) 只是使不同配置的颜色变暗,但保持它们足够明亮,以便可以区分颜色。

输出如下所示:

替代文字

Here's some Python code that will produce what you're looking for. (The example uses 3 configurations rather than 2 to make sure the code was fairly general.)

import matplotlib.pyplot as plt
import random

nconfigs, njobs, nservers = 3, 4, 4

width = .9/(nconfigs*njobs)  
job_colors = [(0,0,1), (0,1,0), (1,0,0), (1,0,1)]

def dim(color, fraction=.5):
    return tuple([fraction*channel for channel in color])

plt.figure()
x = 0
for iserver in range(nservers):
    for ijob in range(njobs):
        for iconfig in range(nconfigs):
            color = dim(job_colors[ijob], (iconfig+2.)/(nconfigs+1))
            plt.bar(x, 1.+random.random(), width, color=color)
            x += width
    x += .1

plt.show()

This code is probably fairly transparent. The odd term (iconfig+2.)/(nconfigs+1) is just to dim the colors for the different configurations, but keep them bright enough so the colors can be distinguished.

The output looks like:

alt text

万人眼中万个我 2024-08-08 18:20:01

最近,我看到一张图表,我认为它可以满足您的需求
protovis

我没有该程序的经验,但该图很有启发性我想会给你想要的。

Recently, I saw a graph that I think does what you want using
protovis

I have no experience with the program, but the graph was enlightening and I think would give you want you want.

白云不回头 2024-08-08 18:20:01

MathGL 可以轻松做到这一点,而且它也有 Python 接口。 有关示例,请参阅

MathGL can do it easily and it have Python interface too. See this for examples.

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