# Trying to create an interactive plot (newbie here)

I'm new at Mathematica so please bear with me. I am trying to create an interactive plot that will end up looking like this: I want to input values for certain variables and then plot a curve. This is what I have now.


Manipulate[
Plot[
y = -((P*x^2)/(6*R*S)) (3*a - x),
{x, 0, 10}],
{P, 0, 10},
{R, 0, 10},
{S, 0, 10},
{a, 0, 10}
]


Instead of slider bars, I want to have input boxes.

I have a few other issues. I don't know how to program a square. I believe this should be done piecewise, but I'm not sure how to do it on the same plot as my curve. Also, I'd like it so that the y-intercept auto manipulates so that the curve always touches the corner of the square. This might be a tad harder because I also want to add


y = -((P*x^2)/(6*R*S)) (3*a - x)cos[[Theta]]


Is that even possible?

Thanks for the help.

edit: working off of @MarcoB 's advice, I got this now.


Manipulate[
Show[
Graphics[{Rectangle[{1, 2}, {2, 4}]}],
Plot[
-(Px^2/6) (3 - x),
{x, 0, 1}],
{P, 2, 10}
]
]


edit 2: Working off of @MarcoB 's next comment, I managed to get a plot looking like this:

My code is:


Manipulate[
Show[
Graphics[{Rectangle[{1, 2}, {2, 3}]}],
Plot[
-(Px^2/6) (3 - x),
{x, -2, 10},
PlotStyle -> green],
PlotRange -> {{-2, 10}, {-2, 10}},
Axes -> True
],
{P, -10, 10}
]


• Generally speaking, get the plot working with some fixed values first, then implement the manipulate functionality. More specifically, 1. Remove the y = in your plotting expression; 2. look up Rectangle, Graphics, and Show, in a combination as Show[Graphics[{Rectange[yourspecs]}], Plot[plottingArguments]]; 3. See InputField as a control type for Manipulate. Commented May 18, 2016 at 14:50
• @MarcoB I'm getting this error message "Could not combine the graphics objects in Show[...] From reading the help menu, it would appear as though this is because my equation isn't a "graphics expression". How can I fix this? Commented May 18, 2016 at 21:35
• Can you show the exact code you tried? Commented May 18, 2016 at 21:51
• It doesn't seem to show up well in the comment. I'll add it to my original post. Commented May 19, 2016 at 2:50
• The {P, 2, 10} fragment should be inside Manipulate, but outside Show, so ... {x, 0, 1}]], {P, 2, 10}] Commented May 19, 2016 at 3:16

Manipulate[Show[{

Graphics[{Opacity[0.5], Red,
Rectangle[{1 + a, c + b}, {2 + a, 4 + b}]},
PlotRange -> {{0, 2}, {-3, 0}}, Axes -> True,
AxesOrigin -> {1 + a, c}],

Plot[{-(P*x^2/6) (3 - x), -k*x}, {x, 0, 1}, Axes -> True]
}],

{P, 2, 10}, {a, -1, 1}, {b, -5, 1}, {c, 1, 5}, {k, 0, 3},
SaveDefinitions -> True]


• Thank you so much for this. Let me try to understand it now :) Commented May 19, 2016 at 13:31