Exemple #1
0
def scatter(data_1, data_2, panel=None, pointsize=None, width=400, height=400, xlabel=None, ylabel=None, title="VisAD Scatter", bottom=None, top=None, color=None):
  """
  Quick plot of a scatter diagram between <data_1> and <data_2>.
  <panel> is the name of a panel to put this into (default= make a new
  one), <pointsize> is the size of the scatter points (def = 1),
  <width> and <height> are the dimensions, <xlabel> and <ylabel> are
  the axes labels to use (def = names of data objects).  <title> is
  the phrase for the title bar.  Returns a reference to the display.
  """

  if isinstance(data_1,PyList) or isinstance(data_1,PyTuple):
    data_1 = field('data_1',data_1)

  if isinstance(data_2,PyList) or isinstance(data_2,PyTuple):
    data_2 = field('data_2',data_2)

  rng_1 = data_1.getType().getRange().toString()
  rng_2 = data_2.getType().getRange().toString()
  data = FieldImpl.combine((data_1,data_2))
  maps = subs.makeMaps(getRealType(rng_1),"x", getRealType(rng_2),"y")
  disp = subs.makeDisplay(maps)
  subs.addData("data", data, disp, constantMaps=subs.makeColorMap(color))
  subs.setBoxSize(disp, .70)
  showAxesScales(disp,1)
  #setAxesScalesFont(maps, Font("Monospaced", Font.PLAIN, 18))
  if pointsize is not None: subs.setPointSize(disp, pointsize)

  subs.setAspectRatio(disp, float(width)/float(height))
  subs.showDisplay(disp,width,height,title,bottom,top,panel)
  setAxesScalesLabel(maps, [xlabel, ylabel])
  return disp
Exemple #2
0
def scatter(data_1,
            data_2,
            panel=None,
            pointsize=None,
            width=400,
            height=400,
            xlabel=None,
            ylabel=None,
            title="VisAD Scatter",
            bottom=None,
            top=None,
            color=None):
    """
  Quick plot of a scatter diagram between <data_1> and <data_2>.
  <panel> is the name of a panel to put this into (default= make a new
  one), <pointsize> is the size of the scatter points (def = 1),
  <width> and <height> are the dimensions, <xlabel> and <ylabel> are
  the axes labels to use (def = names of data objects).  <title> is
  the phrase for the title bar.  Returns a reference to the display.
  """

    if isinstance(data_1, PyList) or isinstance(data_1, PyTuple):
        data_1 = field('data_1', data_1)

    if isinstance(data_2, PyList) or isinstance(data_2, PyTuple):
        data_2 = field('data_2', data_2)

    rng_1 = data_1.getType().getRange().toString()
    rng_2 = data_2.getType().getRange().toString()
    data = FieldImpl.combine((data_1, data_2))
    maps = subs.makeMaps(getRealType(rng_1), "x", getRealType(rng_2), "y")
    disp = subs.makeDisplay(maps)
    subs.addData("data", data, disp, constantMaps=subs.makeColorMap(color))
    subs.setBoxSize(disp, .70)
    showAxesScales(disp, 1)
    #setAxesScalesFont(maps, Font("Monospaced", Font.PLAIN, 18))
    if pointsize is not None: subs.setPointSize(disp, pointsize)

    subs.setAspectRatio(disp, float(width) / float(height))
    subs.showDisplay(disp, width, height, title, bottom, top, panel)
    setAxesScalesLabel(maps, [xlabel, ylabel])
    return disp
Exemple #3
0
def testvisad():
    from visad import RealType, Real, FunctionType, FlatField, RealTuple
    from visad.java3d import DisplayImplJ3D, DirectManipulationRendererJ3D
    from visad.java2d import DisplayImplJ2D, DirectManipulationRendererJ2D
    import subs

    # make Types for our data
    ir_radiance = RealType("ir_raidance")
    count = RealType("count")
    ir_histogram = FunctionType(ir_radiance, count)
    vis_radiance = RealType("vis_radiance")

    # make up the data values...
    histogram = FlatField.makeField(ir_histogram, 64, 0)
    direct = Real(ir_radiance, 2.0)
    direct_tuple = RealTuple( (Real(count, 1.0), Real(ir_radiance,2.0), Real(vis_radiance, 1.0)) )

    # create the scalar mappings for display 0
    maps0=subs.makeMaps(vis_radiance,"z", ir_radiance,"x",
                                        count, "y", count,"green")
    # make display 0 a 3-D display
    dpys0 = subs.makeDisplay3D(maps0)
    subs.setPointSize(dpys0, 5.0)

    # add the data to display 0 and keep the references
    ref_hist = subs.addData("histo", histogram, dpys0,
                    renderer=DirectManipulationRendererJ3D())
    ref_dir = subs.addData("dir", direct, dpys0,
                    renderer=DirectManipulationRendererJ3D())
    ref_dir_tuple = subs.addData("dir_tup", direct_tuple, dpys0,
                    renderer=DirectManipulationRendererJ3D())

    # create the scalar mappings for display 1
    maps1 = subs.makeMaps(ir_radiance,"x", count,"y", count,"green")

    # make display 1 a 2-D display
    dpys1 = subs.makeDisplay2D(maps1)
    subs.setPointSize(dpys1, 5.0)

    # add the data to this display, but use the references from
    # the previous one so the direct manipulations interact with both
    subs.addData("histo", histogram, dpys1,
            renderer=DirectManipulationRendererJ2D(), ref=ref_hist)
    subs.addData("dir", direct, dpys1,
            renderer=DirectManipulationRendererJ2D(), ref=ref_dir)
    subs.addData("dir_tup", direct_tuple, dpys1,
            renderer=DirectManipulationRendererJ2D(), ref=ref_dir_tuple)

    # function to clean up when display window is closed
    def cleanup(event):
        dpys0.destroy()
        dpys1.destroy()
        frame.dispose()

    # create window for display and add the dspy displays to it
    from javax.swing import JPanel, JFrame
    from java.awt import GridLayout
    panel1 = JPanel()
    panel1.add(dpys0.getComponent())
    panel2 = JPanel()
    panel2.add(dpys1.getComponent())

    frame = JFrame("Test35", windowClosing=cleanup)
    pane = frame.getContentPane()
    pane.setLayout(GridLayout(1,2))
    pane.add(panel1)
    pane.add(panel2)
    frame.setSize(600,300)
    frame.setVisible(1)