Announcement

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

  • Title size in coefplot graphs

    Dear Stata users,

    I am using user-written "coefplot" function to plot coefficients and standard error from two models, estimates stored as "firms" and "empl". Below is the code I use and the graph i get. My question is, how do i adjust the size of the titles of the graphs? i.e. make "Firms" and "Employment" larger? Although the task seems trivial, I don't seem to be able to find the answer.


    Code:
    coefplot (firms), bylabel(Firms) ///
               || (empl), bylabel(Employment) ///
               || ,xlabel(-0.02 "-2%" 0 "0"  0.02 "2%" 0.04"4%") ///
                    drop(_cons) xline(0) keep(new_land new_interest) ///
                byopts(rows(1)) xsize(8) ylabel(,labsize(vlarge)) xlabel(,labsize(large))
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	65.2 KB
ID:	1488183
    Attached Files

  • #2
    There are different sources for user-written commands, so it is not sufficient to identify a command as such. What is more important is the source. coefplot is from SSC. The convention is similar to other Stata graphs, implying that you need to include the title() option

    Code:
    coefplot ... ,  title("My title", size(large))
    See

    Code:
    help textsizestyle
    for a selection of available text sizes.

    Comment


    • #3
      Andrew,

      Thank you for the answer. I've tried this option and it does not do what I want. Below is the code and the result I get. As you can see, this option gives the same title for both graphs, and both titles are outside of the graphs. If I specify the title for 'empl', the second title is used for both graphs. If i insert "title("My title", size(large))" after comma, it overwrites any titles before that and again gives all graphs the same title (This is annoying because I also wanted to create one title centered between two graphs). Am I doing something wrong?

      As for the command source, how can I know the source for future posts?


      Code:
          
      
      coefplot (firms), title("My title", size(large)) ///
                 || (empl), title("My title2", size(large)) ///
                 || ,xlabel(-0.02 "-2%" 0 "0"  0.02 "2%" 0.04"4%") ///
                      drop(_cons) xline(0) keep(new_land new_interest) ///
                  byopts(rows(1)) xsize(8) ylabel(,labsize(vlarge)) xlabel(,labsize(large))
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	70.0 KB
ID:	1488201

      Comment


      • #4
        Thank you for the answer. I've tried this option and it does not do what I want. Below is the code and the result I get. As you can see, this option gives the same title for both graphs, and both titles are outside of the graphs. If I specify the title for 'empl', the second title is used for both graphs. If i insert "title("My title", size(large))" after comma, it overwrites any titles before that and again gives all graphs the same title (This is annoying because I also wanted to create one title centered between two graphs). Am I doing something wrong?
        With subgraphs, you have subtitles. You can issue one command that will affect the rendition of all subtitles in the graph.

        Code:
        coefplot ... ,  subtitle(, size(large))

        As for the command source, how can I know the source for future posts?
        You must have installed the command at some point, so the source is where you installed it from. The 3 main sources are SSC, Stata Journal and GitHub. You can type

        Code:
        findit [command name]
        and Stata will give you some guidance. Doing that for coefplot, I find that even though the command is available at SSC, the definitive source is Stata Journal. So this serves to correct my assertion in #2.


        ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        search for coefplot (manual: [R] search)
        ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        Search of official help files, FAQs, Examples, SJs, and STBs

        SJ-15-1 gr0059_1 . . . . . . . . . . . . . . . . Software update for coefplot
        (help coefplot if installed) . . . . . . . . . . . . . . . . B. Jann
        Q1/15 SJ 15(1):324
        fixed extra observations left behind in the dataset

        SJ-14-4 gr0059 . . . . . Plotting regression coefficients and other estimates
        (help coefplot if installed) . . . . . . . . . . . . . . . . B. Jann
        Q4/14 SJ 14(4):708--737
        alternative of marginsplot that plots results from any
        estimation command and combines results from several models
        into one graph

        Web resources from Stata and other users

        (contacting http://www.stata.com)

        5 packages found (Stata Journal and STB listed first)
        -----------------------------------------------------

        gr0059_1 from http://www.stata-journal.com/software/sj15-1
        SJ15-1 gr0059_1. Update: Plotting regression... / Update: Plotting
        regression coefficients and / other estimates / by Ben Jann, Institute of
        Sociology, University / of Bern, Bern, Switzerland / Support:
        [email protected] / After installation, type help coefplot

        gr0059 from http://www.stata-journal.com/software/sj14-4
        SJ14-4 gr0059. Plotting regression... / Plotting regression coefficients
        and other / estimates / by Ben Jann, Institute of Sociology, University /
        of Bern, Bern, Switzerland / Support: [email protected] / After
        installation, type help coefplot

        Comment


        • #5
          Andrew,

          Thank you for your help. The "subtitle("My title",(size(large))" option changes the size as i wanted, but renames all subtitles. Is there a way to assign different subtitles to a each subgraph or am i doing something wrong here again? One workaround would be to store estimates in"Firms" and "Employment", then I'd not need to change the names in the graph, but i have 9 to 12 model estimates and it be very handy to be able to assign custom subtitles in the graph.

          Also, is there a way to assign ONE title to the graph that will be centered between the subtitles(rather than two identical titles above each subgraph)?

          Thank you!

          Code:
          coefplot (firms), subtitle("My title", size(large)) ///
                     || (empl), subtitle("My title2", size(large)) ///
                     || ,xlabel(-0.02 "-2%" 0 "0"  0.02 "2%" 0.04"4%") ///
                          drop(_cons) xline(0) keep(new_land new_interest) ///
                      byopts(rows(1)) xsize(8) ylabel(,labsize(vlarge)) xlabel(,labsize(large))
          Click image for larger version

Name:	Graph subtitles.png
Views:	1
Size:	67.0 KB
ID:	1488293

          Comment


          • #6
            Thank you for your help. The "subtitle("My title",(size(large))" option changes the size as i wanted, but renames all subtitles. Is there a way to assign different subtitles to a each subgraph or am i doing something wrong here again? One workaround would be to store estimates in"Firms" and "Employment", then I'd not need to change the names in the graph, but i have 9 to 12 model estimates and it be very handy to be able to assign custom subtitles in the graph.
            Don't specify a subtitle

            Code:
            coefplot (firms), subtitle(, size(large))
            Also, is there a way to assign ONE title to the graph that will be centered between the subtitles(rather than two identical titles above each subgraph)?
            For one title, place this within byopts()

            Subtitles with one centered title

            Code:
            coefplot (firms), subtitle(, size(large)) byopts(title("My title"))
            One centered title without subtitles

            Code:
            coefplot (firms), subtitle("", size(large)) byopts(title("My title"))

            Last edited by Andrew Musau; 15 Mar 2019, 08:38.

            Comment


            • #7
              Andrew,
              Thank you, I see what you mean. If i don't specify the subtitle, than the name of estimates is used. Is there a way to specify it instead of using the default name of the estimates results? As I mentioned, I have multiple estimates stored with abbreviations (e.g. FE_firms, RE_firms etc.) and it would be handy to use different estimates but change the name of the subtitle in each subgraph. Is it possible?

              Comment


              • #8
                You will have to define the variable labels beforehand to address this or use the graph editor.

                Comment


                • #9
                  Andrew,

                  Thank you. I think I need to clarify that I model different subplots by different estimates from different models (combining them into one graph), not by variables. How do i specify different labels to have different subtitles in this case?

                  As for one centered title, I tried adding the code "byopts(title("My title"))" and it throws an error (please see below).

                  Code:
                  . coefplot (firms), subtitle("My title", size(large)) ///
                  >            || (empl), subtitle("My title2", size(large)) ///
                  >            || ,xlabel(-0.02 "-2%" 0 "0"  0.02 "2%" 0.04"4%") ///
                  >                 drop(_cons) xline(0) keep(new_land new_interest) ///
                  >             byopts(rows(1)) xsize(8) ylabel(,labsize(vlarge)) xlabel(,labsize(large)) byopts(title("My title"))
                  option byopts() not allowed

                  Comment


                  • #10
                    You already have a byopts() option specified, no need to add a second

                    Code:
                    byopts(rows(1) title("My title"))
                    I think if you can post some data, there is scope for progress.

                    Comment


                    • #11
                      Andrew,

                      I think with your help I've been able to solve the problem. What I need is "bylabel()" option combined with "subtitle()". Thanks for your help.

                      Code:
                       
                       coefplot (firms), bylabel(Firms) subtitle(, size(huge))

                      Comment

                      Working...
                      X