Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}]


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, ciao, Michael E2, m_goldberg, R. M. Mar 28 '14 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.

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 Mar 28 '14 at 0:21
up vote 5 down vote accepted

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 '14 at 16:39
@Sigur: The second example will do the job; just replace the RegionFunction $z<f(a,x)$ with your implicit equation. – Rahul Mar 29 '14 at 20:33

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

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