How do I plot a sine function with each point having a z variable
显示 更早的评论
I would like to plot say a sine function for which I have created two arrays, x and y, where y=sine(x). Now each point (x,y) has an associated z variable defined in a third array z. I would like to plot y with a heat map such that various points on the sine function have different colors based on the z value and the rest of the plot is not colored. An example of such a plot is attached.
I tried imagsc(x,y,z) but that did not work. Any hints would be appreciated.
Vahid
1 个评论
In Matlab HG, lines are a single object and have only a single color. To draw varied-colored "lines" simulating the above plot would entail building an image similar as your initial trial or with HG using scatter with solid markers in close proximity to simulate a line or very short individual line segments with a color map with each (essentially using plot|line as a scatter substitute).
Would make a reasonable (and useful) enhancement request...
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Color and Styling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
