Welcome to Golden Software Support

Grapher Boxplot Label Position (Request label position)

Comments

2 comments

  • Avatar
    Leslie McWhirter

    Hello gschwepp,

    My apologies for the delay in answering you. It is not currently possible to align the labels globally with respect to the plot rather than the value, but I've added your vote for this to our suggestion file. In the meantime, the best option would be to calculate the median from the worksheet and copy/paste that into a text box, which you could position exactly. It would look something like this:

    Sub Main
    
    'Create Grapher as an Object
    Dim Grapher As Object
    Set Grapher = CreateObject("Grapher.Application")
    Grapher.Visible = True
    
    '=======================================================
    'User-defined variables
    '=======================================================
    InFile$ = "C:\Program Files\Golden Software\Grapher 13\Samples\box plot.grf"
    
    yPos = 7.577 'desired y position (page units) for the median values
    xPos = 1.95 'x position (page units) of first box
    xint = 1.5 'interval (page units) of boxes
    
    firstcol = 1 'first column used for box plot
    lastcol = 6 'last column used for box plot
    '=======================================================
    
    'Opens box plot file and initializes graph and plot parameters, and plot data
    Set PlotDoc = Grapher.Documents.Open(InFile$)
    Set Graph = PlotDoc.Shapes.Item(1)
    Set BoxPlot = Graph.Plots.Item(1)
    Set Wks = BoxPlot.DisplayWorksheet
    
    'Loops through box plot columns, calculating median then adding as a text box to the plot
    For i=firstcol To lastcol
        Set stats = Wks.Columns(i).Statistics(True,True,wksStatsAll,wksIncludeAll,0,0)
        med = stats.Median
    
        'Create a text object
        PlotDoc.Activate
        PlotDoc.Shapes.AddText(xPos+(xint*(i-firstcol)),yPos,med)
    Next i
    
    End Sub

     

    Note, if you have multiple plots in the graph, multiple graphs in the project, or multiple files to perform this on, you could probably add additional loops to this script.

    Thanks!

    Leslie McWhirter

    Golden Software

    1
    Comment actions Permalink
  • Avatar
    gschwepp

    Ok. This will get messy, but I think follow your suggestions. 

    Thank you!

    0
    Comment actions Permalink

Please sign in to leave a comment.