How can I use a colormap to color each row in a matrix the same color?
조회 수: 2(최근 30일)
I have two matrices of lat and lon coordinates. Each one is size (25,300), where each column is a measurement and the rows correspond to separate pathways. For example, lat(1,300) is all the latitude measurements for the 1st pathway, and lon(1,300) is all the longitude measurements for the 1st pathway.
I want to plot all of the pathways lats and lons, but each separate pathway has its own color.
I currently have:
Which plots all pathways, but the colormap is changing throughout all measurement (e.g. every measurement has its own color), instead of each row getting its own separate color.
If I run colororder(parula(25)) it also doesn't do what I want. Instead, it plots the first 25 points as one color, then 25 points as the next color, and it does this 25 times then resets to start at the first color.
Essentially, I want it to plot the first row of 300 points as 1 color, then the second row of 300 points as the next color, etc. etc. until the 25 rows are colored.
Stephen23 2022년 6월 15일
편집: Stephen23 2022년 6월 15일
You need to transpose the input matrices, so that PLOT() gets 300*25 matrices:
% ^^ ^^ transpose
Although you write that you "want it to plot the first row of 300 points as 1 color..." the PLOT() function does not plot rows of a matrix and probably never will. For non-vector inputs, PLOT() plots the columns, just as the documentation explains. So the simple solution is to give it exactly the input data that its documentation required: if you want to plot 300 points as one color then those 300 points should be the first column, etc.
Ergo, transpose the input matrices.