MATLAB MATLAB Color Points According to Variable

AI Thread Summary
The discussion focuses on creating a 2D scatter plot in MATLAB, where points are colored based on a third variable representing changes in magnetic field readings. The x-axis represents Kurth Phase, while the y-axis indicates invariant latitude, with the color gradient transitioning from red to blue to signify magnetic field variations. The user seeks guidance on how to implement this color-coding in MATLAB, specifically using the scatter() function to apply a vector for color values. The realization that scatter() can automatically handle color transitions simplifies the process. Overall, the discussion highlights the integration of multiple variables in visualizing spacecraft trajectory and magnetic field changes.
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?
 
Try plotting the points using scatter()...
 
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
Views
7K
Replies
2
Views
2K
Replies
4
Views
2K
Replies
1
Views
22K
Replies
12
Views
4K
Replies
2
Views
3K
Replies
6
Views
5K
Replies
8
Views
2K
Replies
3
Views
3K
Back
Top