Announcement

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

  • How to clear all graphs saved in macro

    Hi, I am 'foreach' loop command to save and combine 9 different catplot (ssc) graphs (local graphnames `graphnames' `x'). If I have to remake the graph, I use
    Code:
    graph drop _all
    , but still end up having 18 graphs in one instead of 9, and have to exit Stata and rerun everything from the beginning. Is there any way to do this without exiting the application?

    Also, the titles are getting overlapped as there are not enough spaces for them. I tried the splitlabel(ssc) functions but it doesn't seem to work. Does catplot have any function to split the labels?

    Please let me know.
    Click image for larger version

Name:	Capture d’écran 2021-06-19 à 08.42.08.png
Views:	1
Size:	701.6 KB
ID:	1615394

    Thank you.

  • #2
    Your
    Code:
    graph drop all
    is dropping all of your graphs. However, it is not resetting the list of graphs to combine that you create in the local macro graphnames, so the second run of your loop adds the same 9 names a second time, and thus the combined graph includes each of the 9 newly-created graphs twice.

    You need to run
    Code:
    local graphnames
    to empty the local macro of the 9 names already in the list, before rerunning your loop.

    Comment

    Working...
    X