Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB Color Points According to Variable

  1. May 26, 2010 #1
    I have been tasked with making a plot with a couple variables of available data. I'm to make a normal 2D scatter plot of the data with respect to 2 of the variables given, easy enough. But then I'm supposed to color (from red to blue) each point according to a 3rd variable, which is a derivative of a couple other variables (getting convoluted yet?). When I asked what this is about I was told its supposed to be a spacecraft orbit around a planet, where x-axis is Kurth Phase (a moving Saturn SKR coordinate), y-axis invariant latitude. And the derivative spoken of earlier is supposed to be changes in the magnetic field readings taken with respect to latitude). So that with the end result you will have a line (of points where the data was taken) representing the spacecraft trajectory but colored to indicate how the magnetic field is changing to signify places where there is strong changes or weak changes.

    When explained it makes sense to me, but I can't see how I'm supposed to code this. What steps do I take to color individual points according to some color scheme/variable?
     
  2. jcsd
  3. May 26, 2010 #2
    I've been thinking a bit on this and I can see I'll need some sort of variable to define the stepping through different color shades, and to define how many shades I'll be wanting. I see the regular "colorbar" command seems to be the right color scheme. But how do I apply to the individual elements of the plot?
     
  4. May 26, 2010 #3

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    Try plotting the points using scatter().....
     
  5. May 27, 2010 #4
    Wow as much as I thought that didn't help I didn't realize the scatter function can take a vector for color values, and it automatically creates equal transitions for the spectrum. Thank you so much!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB Color Points According to Variable
Loading...