MATLAB Color Points According to Variable

Click For Summary

Discussion Overview

The discussion revolves around creating a 2D scatter plot in MATLAB where points are colored according to a third variable, which represents changes in magnetic field readings related to a spacecraft's orbit around a planet. The x-axis corresponds to Kurth Phase, and the y-axis represents invariant latitude.

Discussion Character

  • Technical explanation, Exploratory, Homework-related

Main Points Raised

  • One participant describes the task of plotting data with respect to two variables and coloring points based on a third variable, which is a derivative of other variables.
  • Another participant suggests the need for a variable to define color shades and the number of shades desired for the plot.
  • A suggestion is made to use the "colorbar" command to implement the color scheme.
  • A later reply indicates that the scatter() function can accept a vector for color values, which facilitates automatic transitions in color across the spectrum.

Areas of Agreement / Disagreement

Participants appear to be exploring the technical aspects of the task with no explicit consensus or disagreement noted, as they are building upon each other's contributions to refine their understanding.

Contextual Notes

Participants have not fully resolved how to implement the color scheme in detail, and there may be assumptions regarding the data structure and the specific requirements for the color mapping.

Who May Find This Useful

Individuals interested in data visualization in MATLAB, particularly in the context of scientific data analysis involving spacecraft trajectories and magnetic field readings.

darkfall13
Messages
30
Reaction score
0
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?
 
Physics news on Phys.org
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?
 
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!
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 1 ·
Replies
1
Views
22K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 11 ·
Replies
11
Views
4K