Plotting data on a 2d plane with colorbar

57 views (last 30 days)
Luffy on 15 Oct 2015
Commented: Martin Schätz on 15 Oct 2015
I have 3 vectors of size 1:100 each(say X,Y,Z).I want to plot it on a 2d plane with colorbar indicating depth. I've tried with pcolor but it requires a matrix.
Is this even correct way of doing it ?

Answers (2)

Lessmann on 15 Oct 2015
an easy way of doing this is the scatter plot. Use it like this

Martin Schätz
Martin Schätz on 15 Oct 2015
Hey, in pcolor the X and Y means predefined grid (like from meshgrid ), and Z are actual data. So then X Y and Z has to be matrixes. If you have 1D X and Y and 2D Z then you can use meshgrid to generate 2D X and Y and use pcolor . If you had 1D Z, or all of your X Y Z are actual depth data, then you will have to display them as 1D data, or expand them to actual 2D array, create grid for them and use pcolor to display them. (And display colorbar as u did write in your answer.) Also check examples for pcolor they might help you to understad how this function works.
Martin Schätz
Martin Schätz on 15 Oct 2015
You can just change the last line to this: pcolor([X;Y;Z]). But i dont think that this is what you wanted... Check it out in MatLab.

Sign in to comment.


Find more on Surfaces, Volumes, and Polygons in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!