Example #1
0
    def testColor(self):
        """
        Test suite for color methods
        """

        with self.subTest(msg="color(string)"):
            color = Plot.color("#000000")

        with self.subTest(msg="colorHSL(float, float, float)"):
            color = Plot.colorHSL(0.0, 0.0, 0.0)
        with self.subTest(msg="colorHSL(float, float, float, float)"):
            color = Plot.colorHSL(0.0, 0.0, 0.0, 0.0)

        with self.subTest(msg="colorRGB(int)"):
            color = Plot.colorRGB(0)
        with self.subTest(msg="colorRGB(int, boolean)"):
            color = Plot.colorRGB(0, True)
        with self.subTest(msg="colorRGB(int, int, int)"):
            color = Plot.colorRGB(0, 0, 0)
        with self.subTest(msg="colorRGB(int, int, int)"):
            color = Plot.colorRGB(0, 0, 0, 255)
        with self.subTest(msg="colorRGB(float, float, float)"):
            color = Plot.colorRGB(0.0, 0.0, 0.0)
        with self.subTest(msg="colorRGB(float, float, float, float)"):
            color = Plot.colorRGB(0.0, 0.0, 0.0, 1.0)
        del color

        with self.subTest(msg="colorNames()"):
            names = Plot.colorNames()
            self.assertTrue(isinstance(names, list) and len(names) > 0)
            print("colorNames() values {}".format(names))
Example #2
0
    def testChartMethods(self):
        """
        Test suite for methods inherited from Chart
        """

        figure = figure_wrapper.FigureWrapper(2, 2)
        with self.subTest(msg="chartTitle(string)"):
            figure = figure.chartTitle("Chart Title")
        with self.subTest(msg="chartTitleColor(string"):
            figure = figure.chartTitleColor("BLUE")
        with self.subTest(msg="chartTitleColor(Paint)"):
            figure = figure.chartTitleColor(Plot.colorRGB(0, 0, 255))
        with self.subTest(msg="chartTitleFont(string, string, int)"):
            figure = figure.chartTitleFont("Arial", "B", 20)
        with self.subTest(msg="span(int, int"):
            figure.span(2, 2)
        with self.subTest(msg="colSpan(int)"):
            figure.colSpan(2)
        with self.subTest(msg="rowSpan(int)"):
            figure.rowSpan(2)

        axes = None
        # maybe the wrapping for these is dumb? Should be returning an axes reference?
        with self.subTest(msg="newAxes()"):
            axes = figure.newAxes()
        with self.subTest(msg="newAxes(string)"):
            axes = figure.newAxes("new_axis")
        with self.subTest(msg="newAxes(int)"):
            axes = figure.newAxes(2)
        with self.subTest(msg="newAxes(string, int)"):
            axes = figure.newAxes("new_axis", 2)
        with self.subTest(msg="axes(string)"):
            axes.axes("new_axis")
        with self.subTest(msg="axes(int)"):
            axes.axes(0)  # I'm assuming that 0 will always work?
        del axes

        # TODO: what are the possibilities here? I'm guessing ["horizontal", "vertical"]? Documentation?
        with self.subTest(msg="plotOrientation(string)"):
            figure = figure.plotOrientation("vertical")

        # I have to put a series in here
        figure = figure.plot("Microsoft", self.table.where("Sym=`MSFT`"),
                             "timestamp", "price")
        with self.subTest(msg="legendVisible(boolean)"):
            figure = figure.legendVisible(True)
        with self.subTest(msg="legendFont(string, string, int)"):
            figure = figure.legendFont("Arial", "P", 8)
        with self.subTest(msg="legendColor(string)"):
            # I'm guessing that this is the background color?
            figure = figure.legendColor("#A0A0A0")
        with self.subTest(msg="legendColor(Paint)"):
            figure = figure.legendColor(Plot.colorRGB(200, 200, 200))
        with self.subTest(msg="chartRemoveSeries(*string)"):
            figure.chartRemoveSeries("Microsoft")
        del figure
Example #3
0
    def testMultiSeries(self):
        """
        Test suite for methods inherited from MultiSeries - bah...
        """

        # NB: the error message:
        #   java.lang.UnsupportedOperationException: Series type does not support this method.
        #   seriesType=class io.deephaven.db.plot.datasets.xy.XYDataSeriesTableArray
        #   method='@Override public  FigureImpl pointsVisible( java.lang.Boolean visible, java.lang.Object... keys )'

        # TODO: seriesNamingFunction(*args)?,pointColorByY(func, *keys)?
        # TODO: a ton of other call signatures for basically XYDataSeriesMethods

        figure = Plot.plot("Microsoft", self.table.where("Sym=`MSFT`"), "timestamp", "price")\
            .plot("Apple", self.table.where("Sym=`AAPL`"), "timestamp", "price")

        with self.subTest(msg="gradientVisible(boolean, *keys)"):
            figure = figure.gradientVisible(True, "Microsoft")
        with self.subTest(msg="lineColor(Paint/int/string, *keys)"):
            figure = figure.lineColor("RED", "Apple")
        with self.subTest(msg="lineStyle(LineStyle, *keys)"):
            figure = figure.lineStyle(Plot.lineStyle(4.0, 4.0), "Microsoft",
                                      "Apple")
        with self.subTest(msg="linesVisible(boolean, *keys)"):
            figure = figure.linesVisible(True, "Microsoft", "Apple")
        with self.subTest(msg="pointColor(Paint/int/string, *keys)"):
            figure = figure.pointColor("BLUE", "Microsoft", "Apple")
        with self.subTest(msg="pointLabel(object, *keys)"):
            figure = figure.pointLabel("label", "Microsoft", "Apple")
        with self.subTest(msg="pointLabelFormat(string, *keys)"):
            figure = figure.pointLabelFormat("{0}: ({1}, {2})", "Microsoft",
                                             "Apple")
        with self.subTest(msg="pointShape(string, *keys)"):
            figure = figure.pointShape("SQUARE", "Microsoft", "Apple")
        with self.subTest(msg="pointSize(double, *keys)"):
            figure = figure.pointSize(2.0, "Microsoft", "Apple")
        with self.subTest(msg="pointsVisible(boolean, *keys)"):
            figure = figure.pointsVisible(True, "Microsoft", "Apple")
        with self.subTest(msg="seriesColor(Paint/int/string, *keys)"):
            figure = figure.seriesColor(Plot.colorRGB(255, 0, 0), "Microsoft",
                                        "Apple")
        with self.subTest(msg="tool tips"):
            figure = figure.toolTipPattern("###,###.00", "Apple")\
                .xToolTipPattern("###,###.00", "Apple")\
                .yToolTipPattern("###,###.00", "Apple")
        with self.subTest(msg="group(int, *keys)"):
            figure = figure.group(0, "Microsoft", "Apple")
        del figure
Example #4
0
    def testAxisMethods(self):
        """
        Test suite for methods inherited from Axis - do these apply said methods to every axis? Seems silly.
        """

        figure = figure_wrapper.FigureWrapper()
        # How do I get it to select an axes?

        with self.subTest(msg="axisColor(string)"):
            figure = figure.axisColor("#000000")
        with self.subTest(msg="axisColor(Paint)"):
            figure = figure.axisColor(Plot.colorRGB(0, 0, 255))
        with self.subTest(msg="axisFormatPattern()"):
            figure = figure.axisFormat(
                "###,###.00")  # decimal formatting pattern
        with self.subTest(msg="axisLabel(string)"):
            figure = figure.axisLabel("axis")  # decimal formatting pattern
        with self.subTest(msg="axisLabelFont(string, string, int)"):
            figure = figure.axisLabelFont("Arial", "P", 11)

        with self.subTest(msg="businessTime()"):
            figure = figure.businessTime()

        with self.subTest(msg="businessTime(calendar)"):
            figure = figure.businessTime(Calendars.calendar())

        with self.subTest(msg="min(double)"):
            figure = figure.min(1.0)
        with self.subTest(msg="max(double)"):
            figure = figure.max(10.0)
        with self.subTest(msg="range(double, double)"):
            figure = figure.range(1.0, 10.0)
        with self.subTest(msg="ticks(double)"):
            figure = figure.ticks(1.0)
        with self.subTest(msg="ticks(double[])"):
            figure = figure.ticks([1.0, 2.5, 5.0, 7.5, 10.0])
        with self.subTest(msg="tickFont(string, string, int)"):
            figure = figure.ticksFont("Arial", "I", 9)
        with self.subTest(msg="ticksVisible(boolean)"):
            figure = figure.ticksVisible(True)
        with self.subTest(msg="tickLabelAngle(double)"):
            figure = figure.tickLabelAngle(45.0)  # I'm guessing degrees?
        with self.subTest(msg="minorTicks(int)"):
            figure = figure.minorTicks(2)
        with self.subTest(msg="minorTicksVisible(boolean)"):
            figure = figure.minorTicksVisible(True)

        with self.subTest(msg="log()"):
            figure = figure.log()
        # TODO: where would I get an AxisTransform object?
        # with self.subTest(msg="transform(AxisTransform)"):
        #     figure = figure.transform(what)

        with self.subTest(msg="invert()"):
            figure = figure.invert()
        with self.subTest(msg="invert(boolean)"):
            figure = figure.invert(False)

        del figure
Example #5
0
    def testCatPiePlotTroubles(self):

        val = [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 40, 50, 60]
        cat = [
            "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
            "n"
        ]
        fig = Plot.piePlot("pp2", cat, val)
        del fig
Example #6
0
    def testTheme(self):
        """
        Theme test suite
        """

        with self.subTest(msg="themeNames()"):
            names = Plot.themeNames()
            self.assertTrue(isinstance(names, list) and len(names) > 0)
            print("themeNames() values {}".format(names))
Example #7
0
    def testFont(self):
        """
        Test suite for font methods
        """

        fstyle = None
        with self.subTest(msg="fontStyle(string)"):
            fstyle = Plot.fontStyle("bold_italic")  # not case sensitive

        with self.subTest(msg="font(string, string, int)"):
            font = Plot.font("Arial", "p", 10)  # (family, style, size)
        with self.subTest(msg="font(string, fontstyle, int)"):
            font = Plot.font("Arial", fstyle, 10)

        with self.subTest(msg="fontFamilyNames()"):
            names = Plot.fontFamilyNames()
            self.assertTrue(isinstance(names, list) and len(names) > 0)
            print("fontFamilyNames() values {}".format(names))
        with self.subTest(msg="fontStyleNames()"):
            names = Plot.fontStyleNames()
            self.assertTrue(isinstance(names, list) and len(names) > 0)
            print("fontStyleNames() values {}".format(names))
Example #8
0
    def testDataSeriesMethods(self):
        """
        Test suite for methods inherited from DataSeries
        """

        # TODO: pointColorByY(SerializableFunction)?, pointColorByY(Closure)?

        figure = Plot.plot("Microsoft", self.table.where("Sym=`MSFT`"),
                           "timestamp", "price")
        with self.subTest(msg="linesVisible(boolean)"):
            figure = figure.linesVisible(True)
        with self.subTest(msg="lineColor(Paint)"):
            figure = figure.lineColor(Plot.colorRGB(0.2, 1.0, 0.2))
        with self.subTest(msg="lineStyle(LineStyle)"):
            figure = figure.lineStyle(Plot.lineStyle(4, 4))
        with self.subTest(msg="pointsVisible(boolean)"):
            figure = figure.pointsVisible(True)
        with self.subTest(msg="pointSize(double)"):
            figure = figure.pointSize(2.0)
        with self.subTest(msg="pointLabel(object)"):
            figure = figure.pointLabel("label")
        with self.subTest(msg="pointLabelFormat(string)"):
            figure = figure.pointLabelFormat("{0}: ({1}, {2})")
        with self.subTest(msg="pointShape(string)"):
            figure = figure.pointShape("CIRCLE")
        with self.subTest(msg="seriesColor(Paint)"):
            figure = figure.seriesColor(Plot.colorRGB(0.1, 0.1, 0.1))
        with self.subTest(msg="pointColor(Paint)"):
            figure = figure.pointColor(Plot.colorRGB(1.0, 0.0, 0.0))
        with self.subTest(msg="gradientVisible(boolean)"):
            figure.gradientVisible(False)
        with self.subTest(msg="toolTipPattern(string)"):
            figure = figure.toolTipPattern("###,###.00")
        with self.subTest(msg="xToolTipPattern(string)"):
            figure = figure.xToolTipPattern("###,###.00")
        with self.subTest(msg="yToolTipPattern(string)"):
            figure = figure.yToolTipPattern("###,###.00")
        del figure
Example #9
0
    def testPlot(self):
        """
        plot method calls - possibly expand over time
        """

        # perform basic Plot.plot(name, x, y), where x, y span every pairwise choice from the self.arrays dictionary
        figure = None
        typs = sorted(self.arrays.keys())
        for i, xtyp in enumerate(typs):
            xarray = self.arrays[xtyp]
            for j, ytyp in enumerate(typs):
                yarray = self.arrays[ytyp]
                with self.subTest(msg="plot({}, {})".format(xtyp, ytyp)):
                    series_name = '{}_{}'.format(xtyp, ytyp)
                    figure = Plot.plot(series_name, xarray, yarray).show()
        del figure
Example #10
0
    def testBaseFigure(self):
        """
        Test suite for methods inherited from BaseFigure
        """

        figure = figure_wrapper.FigureWrapper(2, 2)
        with self.subTest(msg="figureTitle(string)"):
            figure = figure.figureTitle("Super Title")
        with self.subTest(msg="figureTitleFont(string, string, int)"):
            figure = figure.figureTitleFont("Arial", "B", 24)
        with self.subTest(msg="figureTitleColor(string)"):
            figure = figure.figureTitleColor(
                "#FF0000")  # named color or RGB hex-string
        with self.subTest(msg="figureTitleColor(Paint)"):
            figure = figure.figureTitleColor(Plot.colorRGB(
                0.0, 1.0,
                0.0))  # create an RGB color using plot convenience function
        with self.subTest(msg="updateInterval(long)"):
            figure = figure.updateInterval(1000)  # in milliseconds

        # Maybe the wrapping for these is dumb?
        chart1, chart2, chart3 = None, None, None
        with self.subTest(msg="newChart()"):
            chart1 = figure.newChart()
        with self.subTest(msg="newChart(int)"):
            chart2 = figure.newChart(0)
        with self.subTest(msg="newChart(int, int)"):
            chart3 = figure.newChart(0, 1)

        with self.subTest(msg="chart(int)"):
            chart1 = chart2.chart(0)
        with self.subTest(msg="chart(int, int)"):
            chart1 = chart3.chart(0, 1)

        with self.subTest(msg="removeChart(int, int)"):
            chart1 = chart3.removeChart(0, 1)
        with self.subTest(msg="removeChart(int)"):
            chart1 = chart2.removeChart(0)
        del chart1, chart2, chart3

        # I have to put a series in here
        figure = figure.plot("Microsoft", self.table.where("Sym=`MSFT`"),
                             "timestamp", "price")

        with self.subTest(msg="figureRemoveSeries(*string)"):
            figure = figure.figureRemoveSeries("Microsoft")
        del figure
from deephaven import Plot
# See print(sorted(dir())) or help('deephaven') for full namespace contents.

# note that we are constraining the data to NYSE business time
import deephaven.Calendars as Calendars
cal = Calendars.calendar("USNYSE")
trades = trades.where("cal.isBusinessTime(ExchangeTimestamp)")

#  ************* HISTOGRAM PLOTTING *************

tHist = db.t("LearnDeephaven", "StockTrades")\
     .where("Date=`2017-08-25`")\
     .view("Sym", "Last", "Size", "ExchangeTimestamp")

plotPriceIntervals = Plot.histPlot("AAPL", tHist.where("Sym=`AAPL`"), "Last", 10)\
     .chartTitle("Price Intervals")\
     .show()

#  ************* CATEGORY HISTOGRAM PLOTTING *************

tHist = db.t("LearnDeephaven", "StockTrades")\
     .where("Date=`2017-08-25`")\
     .view("Sym", "Last", "Size", "ExchangeTimestamp")

catHistTradesBySym = Plot.catHistPlot("Number of Trades", tHist, "Sym")\
     .chartTitle("Trades per Symbol")\
     .show()

#  ************* PIE PLOTTING *************

tPie = db.t("LearnDeephaven", "StockTrades")\
Example #12
0
    def testAxesMethods(self):
        """
        Test suite for methods for non-plotting methods inherited from Axes
        """

        # TODO: x/yTransform(AxisTransform)?, x/yBusinessTime(BusinessCalendar)?

        figure = figure_wrapper.FigureWrapper()  # is there an axes at this point?

        axis = None
        # maybe the wrapping for these is dumb?
        with self.subTest(msg="axis fetchers"):
            axis = figure.axis(0)
            axis = figure.xAxis()
            axis = figure.yAxis()
        del axis

        axes = None
        # maybe the wrapping for these is dumb?
        with self.subTest(msg="twin axis methods"):
            axes = figure.twin()
            axes = figure.twin("new")
            axes = figure.twin(0)
            axes = figure.twin("new", 0)
            axes = figure.twinX()
            axes = figure.twinX("new")
            axes = figure.twinY()
            axes = figure.twinY("new")
        del axes

        with self.subTest(msg="axis formatter methods"):
            figure = figure.xFormatPattern("###,###.00").yFormatPattern("###,###.00")
        with self.subTest(msg="axis color methods"):
            figure = figure.xColor("#202020").yColor("#202020")
            figure.xColor(Plot.colorRGB(1.0, 0.0, 0.0)).yColor(Plot.colorRGB(1.0, 0.0, 0.0))
        with self.subTest(msg="axis labelling methods"):
            figure = figure.xLabel("x axis").yLabel("y axis")
        with self.subTest(msg="axis label font methods"):
            figure = figure.xLabelFont("Arial", "P", 11).yLabelFont("Arial", "P", 11)
        with self.subTest(msg="axis tick font methods"):
            figure = figure.xTicksFont("Arial", "I", 9).yTicksFont("Arial", "I", 9)
        with self.subTest(msg="axis range methods"):
            figure = figure.xRange(1.0, 10.0).yRange(1.0, 10.0)
            figure.xMin(1.0).yMin(1.0)
            figure.xMax(10.0).yMax(10.0)
        with self.subTest(msg="axis ticks methods"):
            figure = figure.xTicks(1.0).yTicks(1.0)
            figure.xTicks([1.0, 2.5, 5.0, 7.5, 10.0]).yTicks([1.0, 2.5, 5.0, 7.5, 10.0])
        with self.subTest(msg="tick visibility methods"):
            figure = figure.xTicksVisible(True).yTicksVisible(True)
            figure = figure.xMinorTicksVisible(True).yMinorTicksVisible(True)
        with self.subTest(msg="minor ticks"):
            figure = figure.xMinorTicks(2).yMinorTicks(2)
        with self.subTest(msg="tick label angles"):
            figure = figure.xTickLabelAngle(45.0).yTickLabelAngle(45.0)

        with self.subTest(msg="axis business time methods"):
            figure.xBusinessTime().yBusinessTime()

        with self.subTest(msg="axis log methods"):
            figure.xLog().yLog()
        with self.subTest(msg="axis inversion methods"):
            figure = figure.xInvert().yInvert()
            figure = figure.xInvert(True).yInvert(True)

        # I have to put a series in here
        figure = figure.plot("Microsoft", self.table.where("Sym=`MSFT`"), "timestamp", "price")
        with self.subTest(msg="plotStyle"):
            figure = figure.plotStyle("Area")  # does this just apply the style to all applicable series? Or?

        # maybe the wrapping for these is dumb?
        series = None
        with self.subTest(msg="series(int)"):
            series = figure.series(0)  # I'm guessing that the int id starts at 0?
        with self.subTest(msg="series(string"):
            series = figure.series("Microsoft")
        del series

        with self.subTest(msg="axesRemoveSeries(*string)"):
            figure = figure.axesRemoveSeries("Microsoft")

        del figure
Example #13
0
cal = Calendars.calendar("USNYSE")
trades = db.t("LearnIris", "StockTrades").where("Date=`2017-08-25`")
trades = trades.where("cal.isBusinessTime(ExchangeTimestamp)")

#  CATEGORY PLOTTING - SINGLE

t1c = db.t("LearnDeephaven", "StockTrades")\
   .where("Date >`2017-08-20`", "USym = `MSFT`")\
   .view("Date", "USym", "Last", "Size", "ExchangeTimestamp")

totalSharesByUSym = t1c.view("Date", "USym",
                             "SharesTraded=Size").sumBy("Date", "USym")

categoryPlot = Plot.catPlot("MSFT", totalSharesByUSym.where("USym = `MSFT`"), "Date", "SharesTraded")\
   .chartTitle("Shares Traded")\
   .show()

# CATEGORY PLOTTING - MULTIPLE

t2c = db.t("LearnDeephaven", "StockTrades")\
   .where("Date >`2017-08-20`", "USym in `AAPL`, `MSFT`")\
   .view("Date", "USym", "Last", "Size", "ExchangeTimestamp")

totalSharesByUSym2 = t2c.view("Date", "USym",
                              "SharesTraded=Size").sumBy("Date", "USym")

categoryPlot2 = Plot.catPlot("MSFT", totalSharesByUSym2.where("USym = `MSFT`"), "Date", "SharesTraded")\
   .catPlot("AAPL", totalSharesByUSym2.where("USym = `AAPL`"), "Date", "SharesTraded")\
   .chartTitle("Shares Traded")\
   .show()
Example #14
0
import deephaven.TableTools as tt
import deephaven.Plot as plt


t = tt.emptyTable(50)\
    .update("X = i + 5", "XLow = X -1", "XHigh = X + 1", "Y = Math.random() * 5", "YLow = Y - 1", "YHigh = Y + 1", "USym = i % 2 == 0 ? `AAPL` : `MSFT`")

p = plt.plot("S1", t, "X", "Y").lineColor("black").show()
p2 = plt.plot("S1", t, "X", "Y").plotStyle("bar").gradientVisible(True).show()
p3 = plt.plot(
    "S1", t, "X",
    "Y").plotStyle("scatter").pointColor("black").pointSize(2).show()
p4 = plt.plot("S1", t, "X", "Y").plotStyle("area").seriesColor("red").show()

p4 = plt.plot3d("S1", t, "X", "X", "Y").show()

pBy = plt.plotBy("S1", t, "X", "Y", "USym").show()
pBy = plt.plot3dBy("S1", t, "X", "X", "Y", "USym").show()

cp = plt.catPlot("S1", t, "X", "Y").lineColor("black").show()
cp2 = plt.catPlot("S1", t, "X",
                  "Y").plotStyle("bar").gradientVisible(True).show()
cp3 = plt.catPlot(
    "S1", t, "X",
    "Y").plotStyle("scatter").pointColor("black").pointSize(2).show()
cp4 = plt.catPlot("S1", t, "X",
                  "Y").plotStyle("area").seriesColor("red").show()

cp = plt.catPlot3d("S1", t, "X", "X", "Y").show()

cpBy = plt.catPlotBy("S1", t, "X", "Y", "USym").show()
Example #15
0
    def testLineStyle(self):
        """
        Test suite for line style construction
        """

        with self.subTest(msg="lineEndStyleNames()"):
            names = Plot.lineEndStyleNames()
            self.assertTrue(isinstance(names, list) and len(names) > 0)
            print("lineEndStyleNames() values {}".format(names))

        with self.subTest(msg="lineJoinStyleNames()"):
            names = Plot.lineJoinStyleNames()
            self.assertTrue(isinstance(names, list) and len(names) > 0)
            print("lineJoinStyleNames() values {}".format(names))

        endStyle, joinStyle = None, None
        with self.subTest(
                msg="lineEndStyle(string)"
        ):  # should be [BUTT, ROUND, SQUARE], not case sensitive
            endStyle = Plot.lineEndStyle("Butt")
        with self.subTest(msg="lineJoinStyle(string)"
                          ):  # should be [BEVEL, MITER, ROUND]
            joinStyle = Plot.lineJoinStyle("Bevel")

        with self.subTest(
                msg="lineStyle(double, lineEndStyle, lineJoinStyle, double...)"
        ):
            ls = Plot.lineStyle(4.0, endStyle, joinStyle, 3.0, 3.0)
        with self.subTest(msg="lineStyle(double, string, string, double...)"):
            ls = Plot.lineStyle(4.0, "butt", "bevel", 3.0, 3.0)
        with self.subTest(msg="lineStyle(double)"):
            ls = Plot.lineStyle(4.0)
        with self.subTest(msg="lineStyle(double, int[])"):
            ls = Plot.lineStyle(4.0, numpy.array([3, 3], dtype=numpy.int32))
        with self.subTest(msg="lineStyle(double, long[])"):
            ls = Plot.lineStyle(4.0, numpy.array([3, 3], dtype=numpy.int64))
        with self.subTest(msg="lineStyle(double, float[])"):
            ls = Plot.lineStyle(4.0, numpy.array([3, 3], dtype=numpy.float32))
        with self.subTest(msg="lineStyle(double, double[])"):
            ls = Plot.lineStyle(4.0, [3.0, 3.0])
        with self.subTest(msg="lineStyle(double...)"):
            ls = Plot.lineStyle(3.0, 3.0)

        with self.subTest(msg="lineStyle(string, string)"):
            ls = Plot.lineStyle("butt", "bevel")
        with self.subTest(msg="lineStyle()"):
            ls = Plot.lineStyle()
        with self.subTest(msg="lineStyle()"):
            ls = Plot.lineStyle()
Example #16
0
# note that we are constraining the data to NYSE business time
import deephaven.Calendars as Calendars
cal = Calendars.calendar("USNYSE")
trades = db.t("LearnIris", "StockTrades").where("Date=`2017-08-25`")
trades = trades.where("cal.isBusinessTime(ExchangeTimestamp)")

# ************* XY SERIES PLOTTING *************

# XY SERIES - SINGLE SERIES

t1 = db.t("LearnDeephaven", "StockTrades")\
    .where("Date=`2017-08-24`", "USym=`AAPL`")

PlotSingle = Plot.plot("AAPL", t1.where("USym = `AAPL`"), "Timestamp", "Last")\
    .xBusinessTime()\
    .show()

# XY SERIES - MULTIPLE SERIES

t2 = db.t("LearnDeephaven", "StockTrades")\
    .where("Date=`2017-08-24`", "USym in `INTC`,`CSCO`")

plotSharedAxis = Plot.plot("INTC", t2.where("USym = `INTC`"), "Timestamp", "Last")\
    .plot("CSCO", t2.where("USym = `CSCO`"), "Timestamp", "Last")\
    .xBusinessTime()\
    .show()

# XY SERIES - MULTIPLE SERIES WITH TWINX

t3 = db.t("LearnDeephaven","StockTrades")\
Example #17
0
# generate shared tables
trades = db.t("LearnDeephaven", "StockTrades")\
   .where("Date=`2017-08-25`")\
   .view("Sym", "Last", "Size", "ExchangeTimestamp")

# note that we are constraining the data to NYSE business time
import deephaven.Calendars as Calendars
cal = Calendars.calendar("USNYSE")
trades = trades.where("cal.isBusinessTime(ExchangeTimestamp)")

totalShares = trades.view("Sym", "SharesTraded=Size").sumBy("Sym")
summaries = db.t("LearnDeephaven",
                 "EODTrades").where("ImportDate=`2017-11-01`")

# XY Series
timePlot = Plot.plot("Microsoft", trades.where("Sym=`MSFT`"), "ExchangeTimestamp", "Last")\
   .show()

multiSeries = Plot.plot("Microsoft", trades.where("Sym=`MSFT`"), "ExchangeTimestamp", "Last")\
   .twinX()\
   .plot("Apple", trades.where("Sym=`AAPL`"), "ExchangeTimestamp", "Last")\
   .chartTitle("Price Over Time")\
   .show()

# Category
categoryPlot = Plot.catPlot("Shares Traded", totalShares, "Sym", "SharesTraded")\
   .chartTitle("Total Shares")\
   .show()

# Pie
pieChart = Plot.piePlot("Shares Traded", totalShares, "Sym", "SharesTraded")\
   .chartTitle("Total Shares")\