Announcement

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

  • gr_edit legend, adding removing keys and labels, editing key style

    Hi all,

    I want to edit a legend from a .gph file.

    Say the gph file corresponds with the following command:

    graph twoway (connected yvar1 xvar) || (rcap yvar_upper1 yvar_lower1 xvar) ///
    twoway (connected yvar2 xvar) || (rcap yvar_upper2 yvar_lower2 xvar)



    Capture d’écran 2023-12-12 à 1.44.46 PM.png

    I want to add in a legend that corresponds with JUST yvar1 and yvar2.

    0. using gr_edit, I want to do the following things.

    1. add in a legend at the bottom
    2. the legend will only have two keys, corresponding respectively with yvar1 and yvar2 (by default the legend will include yvar_upper1 yvar_lower1 yvar_upper2 yvar_lower2 as keys/labels 2, 3, 5, and 6 respectively. I just want keys/labels #1 and #4
    3. the legend will be one row by two columns
    4. the first key/label corresponds with the blue solid line (and has a solid blue line for the key) and the second key/label corresponds with the solid red (and has a solid red line for the key).

    The only thing I've figured out so far is how to change the legend label text. e.g.:
    gr_edit .legend.plotregion1.label[1].text = {"My label 1"}

    I've also figured out to make the legend appear on gr_edit, but this currently displays all six keys/labels, but I can't figure out how to drop the unwanted keys (of course I can just replace the unwanted labels with empty text).

    Would anyone know how to do this?
    Last edited by Jakob Brounstein; 12 Dec 2023, 07:33.

  • #2
    Code:
    help legend_options
    I do not see any reason to resort to the graph editor here.

    Comment


    • #3
      I am using the graph editor because I only have access to the .gph files.

      Comment


      • #4
        If you have the .gph file, you have the data too. Look up "serset" in the manuals. Also, e.g., -ssc describe grexport- (though I've found some glitches with that in the past that I was able to fix.by commenting out a line, I recall).

        There is also discussion of data extraction at https://www.statalist.org/forums/for...ta-graph/page2 , To get get Mead Over's program that is cited there (-gph2x1-)
        Code:
        net from http://digital.cgdev.org/doc/stata/MO/Misc
        and then click on the -gph2x1- link and install.

        Comment


        • #5
          Also see addplot from SSC which won't require you to recreate the graph.

          . ssc desc addplot

          ------------------------------------------------------------------------------------------------------------
          package addplot from http://fmwww.bc.edu/repec/bocode/a
          ------------------------------------------------------------------------------------------------------------

          TITLE
          'ADDPLOT': module to add twoway plot objects to an existing twoway graph

          DESCRIPTION/AUTHOR(S)

          addplot adds twoway plot objects to an existing twoway graph.
          This is useful if you want to add additional objects such as
          titles or extra data points to a twoway graph after it has been
          created. Most of what addplot can do, can also be done by
          rerunning the original graph command including additional options
          or plot statements. addplot, however, might be useful if you have
          to modify a graph for which you cannot rerun the original
          command, for example, because you only have the graph file but
          not the data that were used to create the graph. Furthermore,
          addplot can do certain things that would be difficult to achieve
          in a single graph command (e.g. customizing individual subgraphs
          within a by-graph). addplot also provides a substitute for some
          of the functionality of the graph editor.

          KW: graphics
          KW: graph editing

          Requires: Stata version 9

          Distribution-Date: 20210818

          Author: Ben Jann, University of Bern
          Support: email [email protected]


          INSTALLATION FILES (type net install addplot)
          addplot.ado
          addplot.hlp

          ANCILLARY FILES (type net get addplot)
          addplot.zip
          ------------------------------------------------------------------------------------------------------------
          (type ssc install addplot to install)

          Comment


          • #6
            Andrew and Stephen---these totally get me out of this issue! Thank you both so much!
            Last edited by Jakob Brounstein; 13 Dec 2023, 03:18.

            Comment

            Working...
            X