How can I use a colormap to color each row in a matrix the same color?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jeremy Salerno
el 15 de Jun. de 2022
Comentada: Stephen23
el 15 de Jun. de 2022
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:
colororder(parula(300))
plot(lon,lat,'Marker','o','LineStyle','none')
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.
0 comentarios
Respuesta aceptada
Stephen23
el 15 de Jun. de 2022
Editada: Stephen23
el 15 de Jun. de 2022
You need to transpose the input matrices, so that PLOT() gets 300*25 matrices:
colororder(parula(25))
plot(lon.',lat.','Marker','o','LineStyle','none')
% ^^ ^^ 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.
2 comentarios
Stephen23
el 15 de Jun. de 2022
"What is the meaning of the "." after lon and lat?"
- .' transpose
- ' complex conjugate transpose
If you don't want the complex conjugate then use transpose.
Más respuestas (0)
Ver también
Categorías
Más información sobre Orange en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!