Announcement

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

  • How to modify individual graph's title on combined graph

    Dear Stata users,
    Suppose we have a combined graph that is composed of two individual graphs, let's say them left panel and right panel. Now I want to modify titles of the two panels. How can I achieve? Thank you.
    Code:
    sysuse auto
    twoway connected price mpg, sort name(graph1) title(Title of Graph 1)
    twoway connected weight mpg, sort name(graph2) title(Title of Graph 2)
    graph combine graph1 graph2, name(graph3)
    Click image for larger version

Name:	Graphconbine.png
Views:	1
Size:	98.6 KB
ID:	1676239
    Last edited by Chen Samulsion; 03 Aug 2022, 06:38.

  • #2
    You can use the undocumented gr_edit command.

    Code:
    sysuse auto, clear
    twoway connected price mpg, sort name(graph1, replace) title(Title of Graph 1)
    twoway connected weight mpg, sort name(graph2, replace) title(Title of Graph 2)
    graph combine graph1 graph2, name(graph3, replace)
    
    local titles `" "My title 1" "My title 2"'
    forval i=1/2{
        gr_edit .plotregion1.graph`i'.title.text = {}
        gr_edit .plotregion1.graph`i'.title.text.Arrpush "`:word `i' of `titles''"
    }
    Click image for larger version

Name:	graph3.png
Views:	1
Size:	52.2 KB
ID:	1676243

    Comment


    • #3
      Thank you so much Andrew Musau.
      It seems that this is a complicated question without any easy solution by which I mean ready-made commands.

      Comment

      Working...
      X