Customizing Graph - Statistica Visual Basic - Statistica - Dell Community

Customizing Graph

Customizing Graph

This question is answered

Hello:

I have this code:
 
An.Dialog.ResultsVariables = Var(cont) & " 123 131"
Set g = An.Dialog.CategorizedMeansInteractionPlots
Set g1 = g.Item(1)
g1.Titles(1) = "Plot of Means and Conf. Intervals (95.00%) - " & g1.Plot(1).ActualVariable(scgActualY)
Set C = g1.Content
g1.Plot(1).AxisAssignment(1) = scgAxAssignRight
ChangeAxisScaling C.Axes.YAxis, 0.0, 20.0, 160.0,"Arial", 10
ChangeAxisScaling C.Axes.RYAxis, 0.0, 5.0, 50.0,"Arial", 10
C.Axes.XAxis.SkipValuesState = scgOff
C.Axes.TopAxis.DisplayAutoLabels = False 'Scale values
Set AO = An.RouteOutput(g1)
 
Which gives me this graph:
 
34evq68.jpg
 
 
And I want to get this graph:
 
jq2h52.png
 
 
How can I set it in the svb code? I mean, I just need to untick the option "Spreads>Display inner spreads" in each one of the 3 plots and convert the legend to floating text, but I haven't found the way to set it in the code.
 
Regards!
Verified Answer
  • Hi, Yerko,

    The following code run on a stand-alone (i.e., not part of a workbook) Categorized Mean Interaction Plots graph with three (3) plots will remove the range bars from all three (3) plots.  You should be able to modify it according to your needs.

    Sub Main

                   ' Spreads

                   Dim p As Long

                   Dim oGraphObj_2 As GraphObject

                   Set oGraphObj_2 = ActiveGraphEx.GraphObject

                   Dim oGL_2 As Layout2D

                   Set oGL_2 = oGraphObj_2.Content

                   With oGL_2

                                  Dim oPlot_1_2 As Plot

                                                 For p = 1 To oGL_2.Plots.Count

                                                                Set oPlot_1_2 = .Plots(p)

                                                                With oPlot_1_2

                                                                               Dim oBox_1_2 As Bar

                                                                               Set oBox_1_2 = .Box

                                                                               With oBox_1_2

                                                                                              .DisplayBars = False                                                      'This line makes it go away

                                                                               End With

                                                                End With

                                                 Next p

                   End With

                   Set oGraphObj_2 = Nothing

    End Sub

    As for converting the legend to floating text, the following code (run on the same stand-alone graph) should prove modifiable for your needs:

    Sub Main

                    ' Graph Options

                   Dim oGraphObj_2 As GraphObject

                   Set oGraphObj_2 = ActiveGraphEx.GraphObject

                   oGraphObj_2.Titles.Remove(2)

                   Dim oTextObj_1_2 As TextObject

    Set oTextObj_1_2 = oGraphObj_2.ExtraObjects.AddFixedText("!~\FT,6,,\zCPlotLegendObject\,15,2,,,,,16842752, \zCFormattedPlotNameObject\,15,2,,,,,16842756," & vbCrLf &  "\zCPlotLegendObject\,16,2,1,,,,16842752, \zCFormattedPlotNameObject\,16,2,1,,,,16842756," & vbCrLf & "\zCPlotLegendObject\,16,2,2,,,,16842752,             \zCFormattedPlotNameObject\,16,2,2,,,,16842756,", 0.01, 0.01)

                   With oTextObj_1_2

                                  .Parameters.AnchorPosition = 1

                   End With

                   Set oGraphObj_2 = Nothing

    End Sub

     

All Replies
  • Try :

     

    Dim Plot As PlotBoxWhisker
      Set Plot = C.Plots(1)

      Dim oBar As Bar
      Set oBar = Plot.Whisker
      oBar.DisplayBars =False

     

  • Thanks. I finally solve it adding:

    With An.Dialog
    .PlotConfidenceIntervalsForMeans = False
    End With

    Regards!
  • Hi, Yerko,

    The following code run on a stand-alone (i.e., not part of a workbook) Categorized Mean Interaction Plots graph with three (3) plots will remove the range bars from all three (3) plots.  You should be able to modify it according to your needs.

    Sub Main

                   ' Spreads

                   Dim p As Long

                   Dim oGraphObj_2 As GraphObject

                   Set oGraphObj_2 = ActiveGraphEx.GraphObject

                   Dim oGL_2 As Layout2D

                   Set oGL_2 = oGraphObj_2.Content

                   With oGL_2

                                  Dim oPlot_1_2 As Plot

                                                 For p = 1 To oGL_2.Plots.Count

                                                                Set oPlot_1_2 = .Plots(p)

                                                                With oPlot_1_2

                                                                               Dim oBox_1_2 As Bar

                                                                               Set oBox_1_2 = .Box

                                                                               With oBox_1_2

                                                                                              .DisplayBars = False                                                      'This line makes it go away

                                                                               End With

                                                                End With

                                                 Next p

                   End With

                   Set oGraphObj_2 = Nothing

    End Sub

    As for converting the legend to floating text, the following code (run on the same stand-alone graph) should prove modifiable for your needs:

    Sub Main

                    ' Graph Options

                   Dim oGraphObj_2 As GraphObject

                   Set oGraphObj_2 = ActiveGraphEx.GraphObject

                   oGraphObj_2.Titles.Remove(2)

                   Dim oTextObj_1_2 As TextObject

    Set oTextObj_1_2 = oGraphObj_2.ExtraObjects.AddFixedText("!~\FT,6,,\zCPlotLegendObject\,15,2,,,,,16842752, \zCFormattedPlotNameObject\,15,2,,,,,16842756," & vbCrLf &  "\zCPlotLegendObject\,16,2,1,,,,16842752, \zCFormattedPlotNameObject\,16,2,1,,,,16842756," & vbCrLf & "\zCPlotLegendObject\,16,2,2,,,,16842752,             \zCFormattedPlotNameObject\,16,2,2,,,,16842756,", 0.01, 0.01)

                   With oTextObj_1_2

                                  .Parameters.AnchorPosition = 1

                   End With

                   Set oGraphObj_2 = Nothing

    End Sub

     

  • Thanks!!