Announcement

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

  • How to combine two graphs with different width/height so that x-axes are on same level?

    I do have two "twoway connected plots" that I want to combine side by side of each other.

    (To give an example:
    graph 1: process 1
    graph 2: process 2
    y-axes for both graphs: temperature in process
    x-axes: stage in process)

    The problem is that the second graph has only half of the range values on the x-axis. While graph 1 has 100 points on the x-axis, graph 2 has only 50 points (process 1 has 100 stages, process 2 has 50 stages). If I produce the graphs normally, graph2 will be stretched to the standard size. As such the distances between the data points will be twice as large as in the graph1. This would irritate all readers.

    My aim: I would like to have the same distance between value labels on both axes. That is, the x-axes of graph2 should be the half of the standard/graph1. At the same time, the y-axes need to have the same height.

    I specified - fxsize() - for both graphs and gave the graph1 the double size of graph2. I defined - fysize() - in addition and gave both the same value, 80% of the available size. I then combined both graphs with - graph combine -.

    Unfortunately, the graphs still have slightly different sizes. Although the ticks on the x-axis seem to have the same distance on both graphs, the x-axis of the second graph lies slightly higher than for the first! In the last 4 hours, I have tried with different combinations of - ycommon, ysize(), margins(zeor) etc. - and also manual refinement of the values in - fxsize() - as proposed in another post on this issue. But it just does not work !

    Could anybody please help me by giving a hint how to solve this issue? I can't imagine that there is no way how this could work?

    The threads on the topic I have found so far:

    http://www.stata.com/statalist/archi.../msg00582.html
    http://www.stata.com/statalist/archi.../msg00634.html


    My code:

    * Process 1

    # delimit ;
    twoway connected var1 var2 if process=1,
    msymbol(S) mcolor(gs2) msize(medsmall)
    lcolor(gs2) lwidth(0.3) lpattern(shortdash)
    title("Process 1", size(small)) ytitle("Temperature", size(vsmall)) xtitle("Stage")
    fxsize(100) fysize(80) ylabel(, labsize(vsmall)) graphregion(margin(zero)) plotregion(margin(zero))
    bgcolor(white) graphregion(color(white))
    name(grapha, replace);
    # delimit cr;

    * Process 2
    # delimit ;
    twoway connected var1 var2 if process=2,
    msymbol(S) mcolor(gs2) msize(medsmall)
    lcolor(gs2) lwidth(0.3) lpattern(shortdash)
    title("Process 2", size(small)) ytitle("Temperature", size(vsmall)) xtitle("Stage")
    fxsize(50) fysize(80) ylabel(, labsize(vsmall)) graphregion(margin(zero)) plotregion(margin(zero))
    bgcolor(white) graphregion(color(white))
    name(grapha, replace);
    # delimit cr;
    # delimit cr;

    * combine
    gr combine grapha graphb, row(1) name(graph, replace) iscale(1) ycommon title("Temperature on stage by process", size(small)) graphregion(color(white))



  • #2
    Try to draw the graph with the by() option instead of using graph combine. See this thread for more information: http://www.statalist.org/forums/foru...-graph-combine

    Comment


    • #3
      I agree with Friedrich that the by() option is the more elegant solution. But with graph combine I think that the xcommon option would solve the problem.

      Comment


      • #4
        Many thanks to both of you! I will have a look whether it works with the -by()- option even when the graphs need to have different sizes for the different groups! Thanks again.

        Comment

        Working...
        X