title: Scatterplot with 2 y-axis in R
body: <p>I have the following data in my dataset named &quot;px&quot;</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">anneemut</th>
  <th style="text-align: center;">valeurfonc</th>
  <th style="text-align: right;">sbati</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">2014</td>
  <td style="text-align: center;">696300</td>
  <td style="text-align: right;">321.5</td>
  </tr>
  <tr>
  <td style="text-align: left;">2015</td>
  <td style="text-align: center;">426600</td>
  <td style="text-align: right;">144.5</td>
  </tr>
  <tr>
  <td style="text-align: left;">2016</td>
  <td style="text-align: center;">510000</td>
  <td style="text-align: right;">163.0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>And some other years.</p>
  <p>I'd like to plot this 3 variables in the same chart. I thought about a scatter plot, with y1 = anneemut and y2 = sbati.</p>
  <p>I found this code online :</p>
  <pre><code>par(mar = c(5, 4, 4, 4) + 0.3)   # Additional space for second y-axis
  plot(px$valeurfonc, px$anneemut, pch = 16, col = 2)              
  
  # Create first plot
  par(new = TRUE)                 # Add new plot
  plot(px$anneemut, px$sbati, pch = 17, col = 3,  
  
  # Create second plot without axes
       axes = FALSE, xlab = &quot;&quot;, ylab = &quot;&quot;)
  axis(side = 4, at = pretty(range(px$sbati)))      
  # Add second axis
  mtext(&quot;Avg_surface&quot;, side = 4, line = 3)
  </code></pre>
  <p>Here is the output <a href="https://i.stack.imgur.com/ETTHE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ETTHE.png" alt="enter image description here" /></a></p>
  <p>I cannot manage to change the name of my axis. I tried to do</p>
  <pre><code># Create second plot without axes
       axes = FALSE, xlab = &quot;Price&quot;, ylab = &quot;Year&quot;)
  </code></pre>
  <p>But the initial names don't disappear and then we can't read anything.</p>
  <p>Furthermore, I cannot manage to add all the year in the first y axis, and all the values, in full number, in the x-axis.</p>
  <p>Is there a way to do this in ggplot for instance ?</p>