Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9172723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:25:07+00:00 2026-06-17T16:25:07+00:00

I have 6 linear constraints. I know how to find solution to this problem

  • 0

I have 6 linear constraints. I know how to find solution to this problem both by hand and via r. I am looking for an easy way to obtain illustration for a feasible region.

I tried ggplot2 to do so without any success.

Here are the constraints: x1 >= 0, x2 >= 0, x2 <= 10 and the x2 <= 12 - 2/5 * x1, x2 <= 18 - x1, x2 <= 18 - x1

require(ggplot2)

# x2 <= 12 - 2/5*x1
fun1 = function(x1){
     x2 = 12 - 2/5*x1
     return(x2)
}

# x2 <= 18 - x1
fun2 = function(x1){
    x2 = 18 - x1
    return(x2)
}

# x2 = 44 - 3*x1
fun3 = function(x1){
    x2 = 44 - 3*x1
    return(x2)
}

x1 = seq(0,20)
mydf = data.frame(x1, fun1(x1), fun2(x1),fun3(x1),rep(10,length(x1)))
names(mydf) = c('x1','y1','y2','y3','y4')
mydf$y5 = rep(0,length(x1))

p0 = ggplot(mydf, aes(x = x1)) + 
     coord_cartesian(ylim=c(0,10),xlim = c(0,20))+                      
     geom_line(aes(y = y1), colour = 'blue') +
     geom_line(aes(y = y2), colour = 'green') +
     geom_line(aes(y = y3), colour = 'red') +
     geom_line(aes(y = y4), colour = 'purple') +
     geom_line(aes(y = y5), colour = 'black')

p0 +  geom_area(aes(y = pmin(y1,y2,y3,y4,y5)), fill = 'gray60')

Thanks for your help!

EDIT: removing last y5 from the pmin function does the trick:

 p0 +  geom_area(aes(y = pmin(y1,y2,y3,y4,y5)), fill = 'gray60')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:25:09+00:00Added an answer on June 17, 2026 at 4:25 pm

    My problem was in the last variable y5. Removing it from pmin function did the trick.

    p0 = ggplot(mydf, aes(x = x1)) + 
        coord_cartesian(ylim=c(0,10),xlim = c(0,20))+                      
        geom_line(aes(y = y1), colour = 'blue') +
        geom_line(aes(y = y2), colour = 'green') +
        geom_line(aes(y = y3), colour = 'red') +
        geom_line(aes(y = y4), colour = 'purple') +
        geom_line(aes(y = y5), colour = 'black')
    
    p0 +  geom_area(aes(y = pmin(y1,y2,y3,y4)), fill = 'gray60')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a linear layout with this form <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical
I have a continuous linear programming problem that involves maximizing a linear function over
I had this maybe stupid thought since we have linear time sorting algorithms for
I have a linear actuator that I am sending commands to via Visual C++.
i have a linear regression problem which i solved using: m=lm(value ~ mean, data=d)
I have this linear layout vertical orientation, containing three views, I want first view
I have a Linear Layout for advertisement. This Code works great with Ad Mob.
I have this linear gradient, and I can't figure out why it doesn't work.
Suppose I have a linear recurrence* and I want to find its closed-form 'Binet'
I have a classic linear regression problem of the form: y = X b

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.