How do I create a 3D bubble plot in Grapher with a script?

This article contains Grapher sample script that shows how to create a 3D bubble plot and how to change some of its methods and properties.

 

To run this script:

  1. Copy the script below.
  2. Open Grapher and turn on the Script Manager by clicking View | Display | Script Manager.
  3. Press Ctrl+A to select all of the existing lines in the Script Manager and then press DELETE.
  4. Press Ctrl+V to paste it into the Script Manager.
  5. Click the green arrow Start/Resume icon in the Script Manager.

'This script shows the methods and properties of a 3D XYZ bubble plot
Sub Main

'Initializes Grapher
 Dim GrapherApp, Plot, Graph1, XYZBubblePlot  As Object
 Set GrapherApp = CreateObject("Grapher.Application")
 GrapherApp.Visible = True
 Set Plot = GrapherApp.Documents.Add(grfPlotDoc)

'Creates an XYZ bubble plot
 Set Graph1 = Plot.Shapes.Add3DBubblePlotGraph(GrapherApp.Path + "\samples\bar chart orientations.dat")
 Set XYZBubblePlot = Graph1.Plots.Item(1)

'Set RadiusRange to "Use fixed range"
 XYZBubblePlot.RadiusRange = grfUseFixedRange
 XYZBubblePlot.sizeCol = 3

'Set min and max range values
 XYZBubblePlot.RadiusRangeMin = 1
 XYZBubblePlot.RadiusRangeMax = 30

'Set x and y bubble rotation
 XYZBubblePlot.BubbleXRot = 30
 XYZBubblePlot.BubbleYRot = 75

'Set draw method to wire frame 1
 XYZBubblePlot.DrawMethod = grfWireFrame1

'Set wire frame fill color to blue
 XYZBubblePlot.FillColor = grfColorBlue

'Set wireframe line color to green
 XYZBubblePlot.lineColor = grfColorGreen

'Set line count to 10
 XYZBubblePlot.LineCount = 10

'Set Grad detail
 XYZBubblePlot.GradDetail = 50

'Change size column
 XYZBubblePlot.RadiusRange = grfUseDataRange
 XYZBubblePlot.sizeCol = 3

'Set min and max bubble radii
 XYZBubblePlot.BubbleMin = 0.10
 XYZBubblePlot.BubbleMax = 0.6

'Set the bubble plot gradient fill color
 XYZBubblePlot.LoadColorMap(GrapherApp.Path + "\Color Scales\ChromaDepth.clr")

End Sub

 

Updated September 24, 2018

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.