Note that there are some explanatory texts on larger screens.

plurals
  1. POSet limits on y axis for two dependent variables using facet_grid()
    primarykey
    data
    text
    <p>I have the following dataframe</p> <pre><code> Condition congruency Distance Measure Score liminf limsup ConditionF MeasureF 1 Zero Neutral 0 RTs 445.000 435.000 455.000 Zero RTs 2 Zero Congruent 1 RTs 445.000 435.000 456.000 Zero RTs 3 Zero Congruent 2 RTs 441.000 430.000 451.000 Zero RTs 4 Zero Congruent 3 RTs 432.000 422.000 442.000 Zero RTs 5 Zero Incongruent 1 RTs 449.000 439.000 459.000 Zero RTs 6 Zero Incongruent 2 RTs 449.000 438.000 460.000 Zero RTs 7 Zero Incongruent 3 RTs 453.000 440.000 465.000 Zero RTs 8 All different Neutral 0 RTs 446.000 436.000 456.000 All different RTs 9 All different Congruent 1 RTs 445.000 434.000 455.000 All different RTs 10 All different Congruent 2 RTs 449.000 438.000 461.000 All different RTs 11 All different Congruent 3 RTs 449.000 438.000 461.000 All different RTs 12 All different Incongruent 1 RTs 446.000 436.000 456.000 All different RTs 13 All different Incongruent 2 RTs 447.000 436.000 458.000 All different RTs 14 All different Incongruent 3 RTs 450.000 440.000 461.000 All different RTs 15 Zero Neutral 0 Errors 0.029 0.018 0.039 Zero Errors 16 Zero Congruent 1 Errors 0.023 0.015 0.031 Zero Errors 17 Zero Congruent 2 Errors 0.023 0.014 0.033 Zero Errors 18 Zero Congruent 3 Errors 0.027 0.018 0.036 Zero Errors 19 Zero Incongruent 1 Errors 0.034 0.024 0.044 Zero Errors 20 Zero Incongruent 2 Errors 0.036 0.024 0.048 Zero Errors 21 Zero Incongruent 3 Errors 0.024 0.013 0.035 Zero Errors 22 All different Neutral 0 Errors 0.019 0.013 0.026 All different Errors 23 All different Congruent 1 Errors 0.028 0.017 0.038 All different Errors 24 All different Congruent 2 Errors 0.021 0.011 0.032 All different Errors 25 All different Congruent 3 Errors 0.031 0.022 0.041 All different Errors 26 All different Incongruent 1 Errors 0.024 0.010 0.037 All different Errors 27 All different Incongruent 2 Errors 0.020 0.011 0.029 All different Errors 28 All different Incongruent 3 Errors 0.019 0.010 0.028 All different Errors </code></pre> <p>I want to make a line graph for RTs and Errors (my DVs. Because I want to put them together in the same graph space, I am using face_grid for this:</p> <pre><code>ggplot(matriz, aes(Distance, Score, shape= congruency, linetype=congruency)) + geom_point(size=5) + geom_line(size=1) + geom_errorbar(aes(ymax = limsup, ymin= liminf), width=0.25, linetype=1) + facet_grid(MeasureF~ConditionF,scales= "free") </code></pre> <p>the thing is that I would like to customize each y axis. Specifically, I want to set limits for this axis. This is quite simple if I had a simple graph (I would only need to include the instruction <code>coord_cartesian()</code>), but I don't have idea of how to do it when I use <code>facet_grid()</code>. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COYou currently cannot do this with facet_grid() I believe. But if the graphs do not share a common scale at all (i.e. you're just "putting them together"), then facet_grid() isn't really intended for that anyway. Try using `grid.arrange` from the gridExtra package instead.
      singulars
    2. CO@joran Being able to expand the y-axis ranges with facet_grid is very helpful when you want to quickly compare different time series on the same range of data (using top to down subplot arrangements). For example, comparing the daily price of a stock price over time to the daily volatility of the stock price, all on the same graph/view. grid.arrange is nice, but you have to carefully adjust the x-axis values so that the plots line up nicely with the correct x dates/times.
      singulars
    3. CO@Clay ggplot intentionally makes it difficult to make plots with dual y axis scales (which is essentially what you are describing) because it is widely considered to be bad graphical practice. Whether you happen to find it useful or not doesn't change the fact that facet_grid does not give you the ability to adjust the y axes directly or that `grid.arrange` is a reasonable alternative. Adjusting the data directly, as you show, is also another option.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload