DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Polor Plot

 
Post new topic   Reply to topic    DPlot Forum Index -> Basic
View previous topic :: View next topic  
Author Message
bartj



Joined: 01 Sep 2005
Posts: 6
Location: France

PostPosted: Thu Sep 01, 2005 6:04 am    Post subject: Polor Plot Reply with quote

Can anyone provide some vb(not .net) code for generating a polor plot? The dplot example file: ex03.grf represents what I would like to "see".
Thanks!
_________________
Bart J
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Thu Sep 01, 2005 9:18 am    Post subject: Reply with quote

This will reproduce ex03.grf:

Code:

Option Explicit
Option Base 0
Dim d As DPLOT

Private Sub Command6_Click()

    Dim i As Long
    Dim NP As Long
    Dim X() As Single
    Dim Y() As Single
    Dim PI As Single
    Dim cmds As String
    Dim ret As Long
    Dim DocNum As Long
   
' Plot sin(3*x) from x = 0 to 2PI

    PI = 4# * Atn(1#)
    NP = 1001
    ReDim X(0 To NP - 1) As Single
    ReDim Y(0 To NP - 1) As Single
   
    For i = 0 To NP - 1
        X(i) = (2# * PI * i) / (NP - 1)
        Y(i) = Abs(Sin(3 * X(i)))
    Next i
       
    d.version = DPLOT_DDE_VERSION
    d.DataFormat = DATA_XYYY
    d.MaxCurves = 1
    d.MaxPoints = NP
    d.NumCurves = 1
    d.ScaleCode = SCALE_POLAR
    d.NP(0) = NP
    d.LineType(0) = LINESTYLE_SOLID
    d.Title1 = "abs(sin(3{\sf}))"
    d.Title2 = ""
    d.Title3 = ""
       
    cmds = "[ManualScale(0,0,0,1.2)]"                   ' X limits are ignored
    cmds = cmds & "[TickInterval(2,30,0.2)]"            ' 1st "2" says X interval is in degrees
    cmds = cmds & "[Caption(""DPLOTLIB XY Test"")]"
    cmds = cmds & "[NumberFormat(0,8)]"                 ' PI Fractions
    cmds = cmds & "[ClearEditFlag()][DocMaximize()]"
    DocNum = DPlot_Plot(d, X(0), Y(0), cmds)
 
End Sub


If you want X in degrees rather than the default radians, use

Code:
    d.ScaleCode = SCALE_POLAR + UNITS_POLAR_DEGREES

_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bartj



Joined: 01 Sep 2005
Posts: 6
Location: France

PostPosted: Thu Sep 01, 2005 3:11 pm    Post subject: Thanks Reply with quote

David,

Thanks for the quick reply.

Will look it over.
_________________
Bart J
Back to top
View user's profile Send private message
bartj



Joined: 01 Sep 2005
Posts: 6
Location: France

PostPosted: Fri Sep 02, 2005 3:45 am    Post subject: Another request Reply with quote

Hello,

Am looking at using dplot in an antenna measurement system where I will plot the signal strength on a polor plot. I setup the plot to use degrees instead of radians and then used the folloing to generate some dummy points:

For i = 1 To 360
X(i) = i ' this generates the angular steps
Y(i) = 0.75 ‘ this is my dummy data – will just represent a circle
Next i

Note that I set NP to 361

I note however that there is a line from the origin at zero degrees to the dummy circle. Is there any way to inhibit this line?

Would also like to set the top to be zero degrees and have the angles change in the clockwise direction. Is there an easy way to accomplish this?

Thanks!
_________________
Bart J
Back to top
View user's profile Send private message
bartj



Joined: 01 Sep 2005
Posts: 6
Location: France

PostPosted: Fri Sep 02, 2005 4:46 am    Post subject: 1 question answered Reply with quote

Hello,

I find that I can eliminate the line from the origin(of a polar plot) to the "circle" by changing my starting index from 1 to 0.

For i = 0 To 360
X(i) = i ' this generates the angular steps
Y(i) = 0.75 ' dummy data
Next i

However I would still like to know how to place zero degrees at the top of a polar plot and have the angles step CW and be labeled in degrees.

Thanks again...
_________________
Bart J
Back to top
View user's profile Send private message
bartj



Joined: 01 Sep 2005
Posts: 6
Location: France

PostPosted: Fri Sep 02, 2005 5:28 am    Post subject: 1 step forward, one step back Reply with quote

OK,

I find that I can set the ploar plot rotation axis to be labeled in degrees.

However when I use the following to set zero degrees to the top and to set a CW direction, it "works", but the grid becomes an elipse instead of a circle:

cmds = cmds & "[PolarPlotStyle(3)]"

Is there another approach that will NOT cause the plot to appear as an elipse?

Thanks!
_________________
Bart J
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Fri Sep 02, 2005 9:36 am    Post subject: Reply with quote

Quote:
I find that I can eliminate the line from the origin(of a polar plot) to the "circle" by changing my starting index from 1 to 0.

For i = 0 To 360
X(i) = i ' this generates the angular steps
Y(i) = 0.75 ' dummy data
Next i


Just so we're clear, this is because the examples use Option Base 0. So in your previous example the first X,Y pair was an uninitialized 0,0.

Quote:
I find that I can set the ploar plot rotation axis to be labeled in degrees.

However when I use the following to set zero degrees to the top and to set a CW direction, it "works", but the grid becomes an elipse instead of a circle:

cmds = cmds & "[PolarPlotStyle(3)]"

Is there another approach that will NOT cause the plot to appear as an elipse?


[PolarPlotStyle(7)]

The 4 (3+4=7) is "Forces a circular plot". This is actually a bit of a hack; all it does is set the plot width and height to 5" (or smaller, depending on what will fit). If you want a bigger plot then also use

[Size(1,w,h,1)]

where w=h=size of plot in inches.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> Basic All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group