title: ggplot display Pareto front only for the points that belong to a specific level
body: <p>Libraries being used</p>
  <pre><code>install.packages(&quot;rPref&quot;)
  install.packages(&quot;dplyr&quot;)
  install.packages(&quot;igraph&quot;)
  install.packages(&quot;ggplot&quot;) 
  </code></pre>
  <p>Taking <code>mtcars</code> dataset from R as an example.</p>
  <p>In order to find the Pareto frontier and level value one establish the preferences</p>
  <pre><code>p &lt;- high(mpg) * high(hp) 
  </code></pre>
  <p>Then calculate the level-value w.r.t. p by using top-all</p>
  <pre><code>res &lt;- psel(mtcars, p, top = nrow(mtcars))
  </code></pre>
  <p>When one creates the visualization as follows</p>
  <pre><code>gp &lt;- ggplot(res, aes(x = mpg, y = hp, color = factor(.level))) + geom_point(size = 3)
  </code></pre>
  <p>It will show a plot with the mpg and hp values of mtcars with colors, and each of the color represents the level (proximity to optimum). As follows</p>
  <p><a href="https://i.stack.imgur.com/vvzg8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vvzg8.png" alt="enter image description here" /></a></p>
  <p>If one wants to plot the Pareto front line for every area of all points of a lower level, one can run</p>
  <pre><code>gp + geom_step(direction = &quot;vh&quot;) 
  </code></pre>
  <p>That results in</p>
  <p><a href="https://i.stack.imgur.com/W1uLk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W1uLk.png" alt="enter image description here" /></a></p>
  <p>However, as for one's case only the 1st level is relevant, how does one display only the dots and the specific pareto front for level 1?</p>
  <p>Changing the <code>factor(.level)</code> to <code>factor(1)</code> as</p>
  <pre><code>gp &lt;- ggplot(res, aes(x = mpg, y = hp, color = factor(1))) + geom_point(size = 3)
  </code></pre>
  <p>Gives the following, which is ignoring the previous levels but some that would not belong to Level 1 seem to be featured in it</p>
  <p><a href="https://i.stack.imgur.com/ltB7R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ltB7R.png" alt="enter image description here" /></a></p>