Turnary plot

Q&A for Visual Basic, Visual Basic .NET, and PowerBasic developers using DPlot

Moderator: DPlotAdmin

Post Reply
wombo
Posts: 10
Joined: Thu Feb 19, 2009 3:11 am

Turnary plot

Post by wombo »

I seem to be really struggling for some reason, I think I am just missing on bit of key information.

For now all I am trying to do is convert a set of data in 2 arrays into a turnary plot.


Arrays:

Code: Select all

N=3
ReDim x(N-1)
ReDim x(N-1)
x(0) = 0
y(0) = 0
x(1) = 40
y(1) = 20
x(2) = 20
y(2) = 60
I am using the following to pass to the Dplot_Plot8 command

Code: Select all

        d = New DPLOT
        d.Initialize()
        d.Version = DPLOT_DDE_VERSION
        d.DataFormat = DATA_XYXY
        d.MaxCurves = 2 ' Must be >= number of curves we plot
        d.MaxPoints = N ' Anything >= N will do
        d.NumCurves = 2
        d.ScaleCode = SCALE_TRIANGLE_PLOT
        d.LegendX = 0.05
        d.LegendY = 0.05
        d.NP(0) = N
        d.LineType(0) = LINESTYLE_SOLID
        d.LineType(1) = LINESTYLE_LONGDASH
        d.Title1 = "Data sent to DPlot via DPLOTLIB.DLL"
        d.XAxis = "x"
        d.YAxis = "y"


DocNum = DPlot_Plot8(s, x(0), y(0), cmds)
As you can see it is based on the sample code.

I think the problem is with either my arrays or the DataFormat.

I would be gratful for any help, thank you.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

NumCurves should be 1, unless you really have 2 curves and aren't showing the data for the second one.
Visualize Your Data
support@dplot.com
wombo
Posts: 10
Joined: Thu Feb 19, 2009 3:11 am

Post by wombo »

Ahh thanks for that its all working now.

Now im off to convert it to handle multiple curves
wombo
Posts: 10
Joined: Thu Feb 19, 2009 3:11 am

Post by wombo »

Thanks for that, I have now got it all working with multiple curves.

Heres my current code for future reference




But I have another question I am trying to implement a system where the colour gets darker gradually through the curves, the other option is for the opacity to gradually go from 100 to 0.

I havent been able to get this up and running properly yet is there any chance you could give me some pointers.
I have been using this thread for pointers but couldnt get it to work http://www.dplot.com/forums/viewtopic.p ... stomcolors

BTW I noticed some where that opacity wasnt passed to metafiles which I think might affect me unless there is a way around that.
wombo
Posts: 10
Joined: Thu Feb 19, 2009 3:11 am

Post by wombo »

It wouldnt let me put it in the previous post

Code: Select all

N = 1
        ReDim x(5, N - 1)
        ReDim y(5, N - 1)

        x(0, 0) = 10
        y(0, 0) = 10
        x(1, 0) = 40
        y(1, 0) = 40
        x(2, 0) = 50
        y(2, 0) = 40
        x(3, 0) = 71
        y(3, 0) = 11
        x(4, 0) = 51
        y(4, 0) = 21
        x(5, 0) = 31
        y(5, 0) = 41

        d = New DPLOT
        d.Initialize()
        d.Version = DPLOT_DDE_VERSION
        d.DataFormat = DATA_XYXY
        d.MaxCurves = 10 ' Must be >= number of curves we plot
        d.MaxPoints = 20 ' Anything >= N will do
        d.NumCurves = 6
        d.ScaleCode = SCALE_TRIANGLE_PLOT
        d.LegendX = 0.05
        d.LegendY = 0.05
        d.NP(0) = N
        d.NP(1) = N
        d.NP(2) = N
        d.NP(3) = N
        d.NP(4) = N
        d.NP(5) = N
        d.LineType(0) = LINESTYLE_NONE
        d.LineType(1) = LINESTYLE_NONE
        d.LineType(2) = LINESTYLE_NONE
        d.SymbolType(0) = SYMBOLSTYLE_HEXAGON
        d.SymbolType(1) = SYMBOLSTYLE_HEXAGON
        d.SymbolType(2) = SYMBOLSTYLE_HEXAGON
        d.SymbolType(3) = SYMBOLSTYLE_HEXAGON
        d.SymbolType(4) = SYMBOLSTYLE_HEXAGON
        d.SymbolType(5) = SYMBOLSTYLE_HEXAGON
        d.Title1 = "Ternary Plot"
        d.XAxis = "x"
        d.YAxis = "y"


        cmds = "[Caption(" & Chr(34) & "Ternary Plot" & Chr(34) & ")]"
        cmds = cmds & "[DocMaximize()][ClearEditFlag()]"
        cmds = cmds & "[SymbolOpacity(0,100)]"
        cmds = cmds & "[SymbolOpacity(1,80)]"
        cmds = cmds & "[SymbolOpacity(2,60)]"
        cmds = cmds & "[SymbolOpacity(3,40)]"
        cmds = cmds & "[SymbolOpacity(4,20)]"
        cmds = cmds & "[SymbolOpacity(5,5)]"


        If (hemf <> 0) Then
            ret = DeleteEnhMetaFile(hemf)
            hemf = 0
        End If
        DocNum = DPlot_Plot8(d, x(0, 0), y(0, 0), cmds)
        ans.Text = DocNum
        If (DocNum > 0) Then
            GetMyMetafile()
            ' Be sure to do a FileClose after this call (if you're done with the document)
            ret = DPlot_Command(DocNum, "[FileClose()]")
        End If
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

SymbolOpacity doesn't work on metafiles - only displays, bitmaps, and printed graphs. There are two reasons DPlot ignores this setting for metafiles: 1) the symbols are drawn device unit by device unit and the "unit" for metafiles is very small - so drawing things this way would yield a very large metafile. Probably more importantly 2) opacity means blending with the background (whatever background happens to be there) and there is no way to retrieve information about the background for a metafile. The only way I could possibly make this work is to throw out one of the primary features of metafiles - a transparent background - and create a large (very, very large) bitmap.
Visualize Your Data
support@dplot.com
wombo
Posts: 10
Joined: Thu Feb 19, 2009 3:11 am

Post by wombo »

Yeah I thought that might be the case.

Do you know how I could acheive something similar using colours. IE going from bright red to black.

I am looking at trending the composition changes over time.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Sure. Just replace all of those SymbolOpacity commands with Color commands. See http://www.dplot.com/help/index.htm?colorcommand.htm

Edit: FYI, the "index" argument is 1-based, not 0-based as you're using with your example and the SymbolOpacity commands.
Visualize Your Data
support@dplot.com
wombo
Posts: 10
Joined: Thu Feb 19, 2009 3:11 am

Post by wombo »

Just a quick note

Thanks for your assistance I have got everything up and running really well. I am now looking into what else we can do with dplot.
Post Reply