Announcement

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

  • Is it possible to obtained an enlarged slice of a graph?

    Dear all,
    First of all it's a pleasure to write my first question here on Statalist. I've found it very useful and I've always tried to search in old discussions for my problems and always found a solution.
    This time instead, I haven't found anything (nor here nor using help or search on Stata), so here I am. I'll try to be as clear as possible.

    I have obtained, from previous steps in my analysis, a dataset of 94 observation with 336 variables, each row containing information over a different country.

    I have three main variables of interest right now, which are ext_input_mean, ext_sales_mean and region_n.
    While the first two are percentages and can go from 0 to 100, region_n is a str1 variable that goes from 1 to 6, with each value identifying a geographical region.

    What I'm doing right now is plotting all the countries situated in region_n == "3" having the other two variables as the graph axis.
    I also want to label those countries that in the graph are situated outside the first quad, plus some others of interest, and I haven't met any problems as of now.

    The code used is the following:
    Code:
    generate sel_country = country if country == "Kosovo" | country=="Armenia" | country=="Estonia" | country=="Sweden" | country=="Romania" | country=="Fyr Macedonia" | country=="Belarus" | country=="Albania" | country=="Montenegro" | country=="Slovenia"
    scatter ext_input_mean ext_sales_mean if region_n=="3", title("Inport/export values for countries grouped by region") subtitle("Europe and Central Asia") xline(50, lpattern(dash)) yline(50, lpattern(dash)) xscale(range(0 100)) yscale(range(0 100)) xtitle("Mean external sales percentage") ytitle("Mean external input percentage") mlabel(sel_country) mlabsize(small)
    while the output is:
    Click image for larger version

Name:	Europe and Central Asia.png
Views:	1
Size:	17.0 KB
ID:	1459341



    As you can see the output is quite chaotic with all those labels so close to each other and of course I'm not satisfied with it, so here's my question:

    Is it possible to only represent a horizontal slice of the graph, of course enlarged?

    What I mean is, for example, to represent only the section going from 40 to 80 of the y axis (ext_input_mean). I've already tried working on the yscale and xscale options, like by modifying that part of code with xscale(range(0 60)) yscale(range(40 80)), but it doesn't really do what I want and instead it returns:
    Click image for larger version

Name:	EUROPE SCHIFO.png
Views:	1
Size:	16.7 KB
ID:	1459342



    I hope that the problem I've presented you is not due to my lack of knowledge in the usage of Stata!
    Thanks in advance!
    Last edited by Dario Bordogna; 23 Aug 2018, 09:28.

  • #2
    You can specify these in your if conditions.
    Code:
    webuse census
    set scheme s1color
    scatter pop marriage if region==3, mlab(state) name(g1)
    *PUT CONSTRAINTS ON X AND Y VARS.
    scatter pop marriage if region==3 & inrange(marriage, 20000, 55000) & inrange(pop, 2000000, 5000000), mlab(state) name(g2)
    gr combine g1 g2

    Click image for larger version

Name:	census.png
Views:	1
Size:	73.3 KB
ID:	1459536

    Comment


    • #3
      Dear Andrew,

      Thank you very much! With few adjustments it wourked out just perfectly!

      Comment

      Working...
      X