example of using avCreateGraph2DObj

example of using avCreateGraph2DObj


I am trying to create a simple 2D graph using the routine


The information provided in the documentation is skethy and not very helpful. There are some sample files but none of them is actually using

avCreateGraph2DObj. The closest example is Threesin, but the use of a template file makes even moredifficultthe understanding.

Basically I have threeone dimensional arrays. The first array is the X and the other two arraysI would like to be the Ys. Once I have computed all three arrays with the IVF how I can make two 2D graphs in Intel Array Viewer?



2 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Community Admin

Hi Leonard,

Welcome to the AV forum!

We're working on improving the documentation for the next release, but in the meantime I think you'll find the example I've come up with fairly helpful. Basically I've taken the ThreeSin sample and converted it to create a graph with 3 plots without using template files. Take a look and let me know if you have any difficulties adapting your program to use a similar technique.

This is the section of the program that creates the graph:


     ! Use the FRT routnine avCreateGraph2D to create a graph object that will contain 
    ! an XYPlot of XSCALE vs. SINX
    call avCreateGraph2D("sine plots", "plot:XYPLOT,xsource:'/data/xscale',ysource:'/data/sinx'", status)
    ! Get a handle to the graph object we just created
    hRoot = avGetObject("/")
    hGraph = avItem(avGraphs(hRoot), "sine plots")
    ! Get a reference to the first (and only) plot object
    hPlot1 = avItem(avPlots(hGraph), 1)
    ! Create a new plot object for the sin2x data
    call avCreatePlot(avPlots(hGraph), "sin2x", AV_XYPLOT, hPlot2)
    ! Use the graph's transform properties
    call avSetInherit(avTransform(hPlot2), 1, status)
    ! Set the X & Y Source
    call avSetXSource(hPlot2, "/data/xscale", status)
    call avSetYSource(hPlot2, "/data/sin2x", status)
    ! Copy the position settings from plot1
    call avGetOrigin(avPosition(hPlot1), vec, status)
    call avSetOrigin(avPosition(hPlot2), vec, status)
    call avGetSize(avPosition(hPlot1), vec, status)
    call avSetSize(avPosition(hPlot2), vec, status)
    ! Set the color to semi-transparent cyan
    call avSetFront(avColor(hPlot2),  avRGBA(0, 255, 255, 150), status)

If you just need a graph that contains one plot (along with horizontal and vertical axes) all you need is the call to avCreateGraph2D. This routine is part of the high-level AV Fortran library: AvFRT. In your case you want to create an additional plot in the graph. To do this we need to use the low-level AV Object Model routines defined in the AvObjMod module. The AvObjMod routines give you more control over the plot settings, but can be a bit more verbose than what you see with the AvFRT routines.

The primary thing that distinguishes the AvObjMod routines is that the first parameter is always a reference to an object. For example, the AvObjMod routine avCreatePlot requires a reference to the Plots object which in turn is a property of the graph object. So we have:

call avCreatePlot(avPlots(hGraph), "sin2x", AV_XYPLOT, hPlot2)

AV_XYPLOT says we want to create an XY plot and the reference to the new plot is returned as hPlot2.

Once we've created the new plot we need to setup its properties for Position, Transform, data source, and color which is what is donein the code following avCreatePlot.

I hope this helps! Let me know what other techniques might be useful to cover in a sample.


Connectez-vous pour laisser un commentaire.