예제 #1
0
파일: plot.py 프로젝트: kovrichard/omnetpp
def hist(x, bins, density, weights, cumulative, bottom, histtype, color, key, label, linewidth,
         underflows, overflows, minvalue, maxvalue):
    swtplot.assert_is_native_chart()

    # check if we really got a precomputed histogram, using the trick documented for pyplot.hist
    if not np.array_equal(x, bins[:-1]):
        raise ValueError("Only precomputed histograms are accepted: the values in `x` must equal the values in `bins`, without the last one.")

    if weights is None or len(weights) != len(x):
        raise ValueError("The `weights` parameter must not be omitted, and it must have the same number of elements as `x`")

    props = {}

    props["Hist.Cumulative"] = str(cumulative)
    props["Hist.Density"] = str(density)

    props["Hist.Color"] = _translate_color(color)
    props["Hist.Bar"] = _translate_histtype(histtype)

    props["Bars.Baseline"] = str(bottom)

    plot_histograms(pd.DataFrame({
        "key": [key],
        "label": [label],
        "binedges": [np.array(bins)],
        "binvalues": [np.array(weights)],
        "underflows": [underflows],
        "overflows": [overflows],
        "min": [float(np.min(bins)) if math.isnan(minvalue) else minvalue],
        "max": [float(np.max(bins)) if math.isnan(maxvalue) else maxvalue]
    }), props)
예제 #2
0
파일: plot.py 프로젝트: kovrichard/omnetpp
def bar(x, height, width, key, label, color, edgecolor):
    swtplot.assert_is_native_chart()
    props = {}

    if color:
        props["Bar.Color"] = _translate_color(color)

    plot_bars(pd.DataFrame(
        {
            "key": [key],
            "label": [str(label)],
            "values": [np.array(height)]
        }
    ), props)
예제 #3
0
파일: plot.py 프로젝트: kovrichard/omnetpp
def plot(xs, ys, key, label, drawstyle, linestyle, linewidth, color, marker, markersize):
    swtplot.assert_is_native_chart()
    props = {}
    if drawstyle:
        props["Line.DrawStyle"] = _translate_drawstyle(drawstyle)
    if linestyle:
        props["Line.Style"] = _translate_linestyle(linestyle)
    if linewidth:
        props["Line.Width"] = str(linewidth)
    if color:
        props["Line.Color"] = _translate_color(color)
    if marker:
        props["Symbols.Type"] = _translate_marker(marker)
    if markersize:
        props["Symbols.Size"] = str(markersize)

    plot_lines(pd.DataFrame({
        "key": [key],
        "label": [label],
        "xs": [np.array(xs)],
        "ys": [np.array(ys)]
        }
    ), props)