Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Axis labels format

    Dear All,


    is there any reason the axis of the chart can't be made formatted as dates/datetimes? (format in the green statement is disregarded)
    I expect the bottom panel to have the same axis labels as the top one.

    I couldn't correct it even with direct editing with the graph editor, despite this format is present in the dialog boxes for the axis.

    See below for the code and screenshot.

    Thank you, Sergiy Radyakin.





    Code:
    version 18.0
    
    clear all
    
    input p
        23392
        23393
        23394
        23395
        23395    
        23395
        23395    
        23395
        23395    
        23395
        23395    
        23395
        23395    
        23395
        23395
        23396
        23397
        23397
        23397
        23397
    end
    
    format p %td
    
    histogram p, name(g1) d freq scale(0.5)
    graph bar , over(p) name(g2) scale(0.5)
    
    graph combine g1 g2, cols(1)
    // end of file

    Click image for larger version

Name:	labels_bar_chart.png
Views:	1
Size:	24.3 KB
ID:	1765887

  • #2
    I've occasionally bumped into the lack of support for display formats with graph bar. There is some related discussion at https://journals.sagepub.com/doi/epu...6867X211000032

    My guess is that this was an oversight insofar as the thinking was that the typical application of graph bar would be to show results different categories for which at most string values or value labels would be the desired display content.

    So, for your case a work-around is to define and use value labels. Example:

    Code:
    clear all
    
    input p
        23392
        23393
        23394
        23395
        23395    
        23395
        23395    
        23395
        23395    
        23395
        23395    
        23395
        23395    
        23395
        23395
        23396
        23397
        23397
        23397
        23397
    end
    
    format p %td
    
    forval date = 23392/23397 {
        local this : di %td `date'
        label def p `date' "`this'", modify 
    }
    
    label val p p 
    
    histogram p, name(g1) d freq scale(0.5)
    graph bar , over(p) name(g2) scale(0.5)
    
    graph combine g1 g2, cols(1)
    // end of file
    As discussed in that SJ Tip, changing to twoway bar would also allow solutions.

    Comment

    Working...
    X