Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

How can I plot a function with one discrete and one continuous input? Plot3D wants everything continuous while ListPlot3D and ListPointPlot3D want everything discrete. I would like be able to say something like

HybridPlot[f[dsc, cnt], {dsc , min, max step}, {cnt, min max}]

or

HybridPlot[f[dsc, cnt], {dsc, someArray}, {cnt, min max}]

I am not seeing a simple way to do this in the docs.

share|improve this question

marked as duplicate by Silvia, rasher, Michael E2, m_goldberg, rm -rf Mar 28 at 5:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Actually I think this is a duplicate of Plotting several functions. Heike's answer there is the same as the one I posted here. –  Rahul Narain Mar 28 at 0:21
add comment

2 Answers 2

If I understand the question correctly, you want to plot $f(a,x)$ as a function of $a$ and $x$, except that $a$ takes discrete values and $x$ lies in a continuous range. Maybe something like

f[a_, x_] := Exp[-x] x^(a - 1)/(a - 1)!

Then the graph of $f$ isn't a surface but a collection of curves $x\mapsto f(a,x)$, one for each discrete value of $a$. You could draw this using a parametric plot like

ParametricPlot3D[Evaluate@Table[{x, a, f[a, x]}, {a, 1, 5}], {x, 0, 10}, BoxRatios -> 1]

enter image description here

or maybe (this one is quite a hack)

ParametricPlot3D[Evaluate@Table[{x, a, z}, {a, 1, 5}], {x, 0, 10}, {z, 0, 0.5},
 RegionFunction -> Function[{x, a, z}, z < f[a, x]],
 BoxRatios -> 1, Mesh -> None, BoundaryStyle -> Black, MaxRecursion -> 5,
 Lighting -> {{"Ambient", LightGray}}]

enter image description here

share|improve this answer
    
How to adapt your solution to plot curves given by implicit equations? For example, the family of circles $x^2+y^2=r^2$ for $1\leq r \leq 2$ plotted at different heights with respect to the radius. –  Sigur Mar 29 at 16:39
1  
@Sigur: The second example will do the job; just replace the RegionFunction $z<f(a,x)$ with your implicit equation. –  Rahul Narain Mar 29 at 20:33
add comment

You can combine the plots with something like Show:

p1 = Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, PlotRange -> {{-3, 3}, {-2, 2}, 
                                                                {-1, 1}}]
p2 =ListPlot3D[Flatten[Table[{x, y, Sin[-x + y^2] + .1}, {x, -3, 3, .1}, {y, -2, 
     2, .1}], 1], ColorFunction -> "SouthwestColors"]

Show[{p1, p2}]

You could also look at Prolog and Epilog to accomplish similar - lots of ways to skin this cat...

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.